package eu.gressly.util;
import java.util.Iterator;
/**
* @author phi@gressly.eu
* @version 1.2: 2013-07-03
*
* A simple to use "Integer"-sequecer for the java "foreach" loop.
* Provides Iterators like 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. */ public class Sequencer { /** * Sequencer starting from "min" (inclusive) ending at "max" (inclusive) * Use like this: *
for(int x : seq(7, 9)) { doSomething(x); }
*/
public static Iterableseq
.
* @see seq()
*/
public static Iterablefor(int x : ord(6)) { diceNumber(x); }
*/
public static Iterablefor(int x : card(9)) { everyDigit(x); }
*/
public static Iterable