pl.netanel.swt.matrix
Interface NumberSeq<N extends java.lang.Number>

All Superinterfaces:
java.lang.Iterable<N>

public interface NumberSeq<N extends java.lang.Number>
extends java.lang.Iterable<N>

Experimental!. Iterates over numbers. The advantage over iterator is the ability to restart and to return the current item in the iteration more than once.

Common idiom for sequence iteration:

 for (seq.init(); seq.next();) {
   System.out.println("Number: " + seq.number());
 }
 


Method Summary
 java.lang.String asString()
           
 void init()
          Initializes the iteration.
 N item()
          Returns the current number in the sequence.
 boolean iter()
          Tries to make the iteration and returns false if it could not be done because the sequence has reached the end.
 java.util.Iterator<N> iterator()
          Returns number iterator.
 N level()
           
 N next()
           
 

Method Detail

init

void init()
Initializes the iteration. Rewinds if it was iterated before. Should be always called before iter() is called for the first time.


iter

boolean iter()
Tries to make the iteration and returns false if it could not be done because the sequence has reached the end. Otherwise on successful iteration returns true.

Returns:
true if the iteration has been successful or false otherwise.

item

N item()
Returns the current number in the sequence.

Returns:
the current number in the sequence

level

N level()

next

N next()

iterator

java.util.Iterator<N> iterator()
Returns number iterator. Costs creation of extra object on each iteration step compared to the sequence iteration.

Specified by:
iterator in interface java.lang.Iterable<N extends java.lang.Number>
Returns:
number iterator

asString

java.lang.String asString()


Copyright © 2011 netanel.pl. All Rights Reserved.