peersim.util
Class LinearIterator

java.lang.Object
  extended by peersim.util.LinearIterator
All Implemented Interfaces:
IndexIterator

public class LinearIterator
extends java.lang.Object
implements IndexIterator

This class gives the linear order 0,1,etc or alternatively k-1, k-2, etc., depending on the constructor.


Constructor Summary
LinearIterator()
          Construct an iterator for an empty set of numbers.
LinearIterator(boolean rev)
          Construct an interator for an empty set of numbers.
 
Method Summary
 boolean hasNext()
          Returns true if IndexIterator.next() can be called at least one more time.
 int next()
          Returns next index.
 void reset(int k)
          This resets the iteration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearIterator

public LinearIterator()
Construct an iterator for an empty set of numbers. You have to call reset(int) to actually fully initialize the object. The numbers returned by consecutive calls to next() are 0,1,...


LinearIterator

public LinearIterator(boolean rev)
Construct an interator for an empty set of numbers. You have to call reset(int) to actually fully initialize the object. If parameter is true then the numbers returned by consecutive calls to next() are k-1,k-2,..., otherwise 0,1,...

Method Detail

reset

public void reset(int k)
Description copied from interface: IndexIterator
This resets the iteration. The set of integers will be 0,..,k-1.

Specified by:
reset in interface IndexIterator

next

public int next()
Returns next index. The indices are returned in increasing or decreasing order depending on the parameter given at construction time.

Specified by:
next in interface IndexIterator

hasNext

public boolean hasNext()
Description copied from interface: IndexIterator
Returns true if IndexIterator.next() can be called at least one more time. Note that IndexIterator.next() can be called k times after IndexIterator.reset(int).

Specified by:
hasNext in interface IndexIterator