eu.gressly.util
Class Sequencer

java.lang.Object
  extended by eu.gressly.util.Sequencer

public class Sequencer
extends java.lang.Object

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.
Author:
phi@gressly.eu

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

Sequencer

public Sequencer()
Method Detail

seq

public 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); }


range

public static java.lang.Iterable<java.lang.Integer> range(int min,
                                                          int max)
Another word for seq.

See Also:
seq()

ord

public static java.lang.Iterable<java.lang.Integer> ord(int last)
Ordinal numbers (starting at 1 = "first"; 2 = "second"; ...) ending at "last" (inclusive). Ordinal numbers always start at first (1.). Use like this: for(int x : ord(6)) { diceNumber(x); }


card

public static java.lang.Iterable<java.lang.Integer> card(int max)
Cardinal numbers (starting at 0) ending at "max" (inclusive). Cardinal numbers describe "how many elements" (this can be zero). Use like this: for(int x : card(9)) { everyDigit(x); }