|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecteu.gressly.util.Sequencer
public class Sequencer
ord() and card().
Simply use
for(int x : range(min, max))
instead of incrementing yourself:
for(int x = min; x <= max; x = x + 1).
Example to produce all domino stones:
import static ch.programmieraufgaben.iteration.Sequencer.seq;
for(int first : card(6)) {
for(int second : range(first, 6)) {
System.out.println("("+ first + "|" + second + ")");
}
}
Or simply use a code 100 times:
for(int i : ord(100)) {
myCode(i); }
History: first Implementation: May 26, 2009
Bugs : not yet known any, not yet known all.| Constructor Summary | |
|---|---|
Sequencer()
|
|
| Method Summary | |
|---|---|
static java.lang.Iterable<java.lang.Integer> |
card(int max)
Cardinal numbers (starting at 0) ending at "max" (inclusive). |
static java.lang.Iterable<java.lang.Integer> |
ord(int last)
Ordinal numbers (starting at 1 = "first"; 2 = "second"; ...) ending at "last" (inclusive). |
static java.lang.Iterable<java.lang.Integer> |
range(int min,
int max)
Another word for seq. |
static java.lang.Iterable<java.lang.Integer> |
seq(int min,
int max)
Sequencer starting from "min" (inclusive) ending at "max" (inclusive) Use like this: for(int x : seq(7, 9)) { doSomething(x); } |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Sequencer()
| Method Detail |
|---|
public static java.lang.Iterable<java.lang.Integer> seq(int min,
int max)
for(int x : seq(7, 9)) { doSomething(x); }
public static java.lang.Iterable<java.lang.Integer> range(int min,
int max)
seq.
seq()public static java.lang.Iterable<java.lang.Integer> ord(int last)
for(int x : ord(6)) { diceNumber(x); }
public static java.lang.Iterable<java.lang.Integer> card(int max)
for(int x : card(9)) { everyDigit(x); }
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||