kodkod.util.collections
Class Iterators

java.lang.Object
  extended by kodkod.util.collections.Iterators

public final class Iterators
extends java.lang.Object

This class provides utility methods for constructing iterators.

Author:
Emina Torlak

Constructor Summary
Iterators()
           
 
Method Summary
static
<T> java.util.Iterator<T>
emptyIterator()
          Returns an iterator that has no elements.
static
<T,E extends T>
java.util.Iterator<T>
iterate(E... items)
          Returns a new iterator over the given array of items.
static
<T,E extends T>
java.util.Iterator<T>
iterate(int start, int end, E... items)
          Returns a new iterator over the given array of items.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Iterators

public Iterators()
Method Detail

iterate

public static final <T,E extends T> java.util.Iterator<T> iterate(E... items)
Returns a new iterator over the given array of items. The iterator is backed by the given array. The contents of the array are not modified by the iterator. The effect of this method is the same as calling Iterators.iterator(0, items.length, items).

Throws:
java.lang.NullPointerException - - items = null

iterate

public static final <T,E extends T> java.util.Iterator<T> iterate(int start,
                                                                  int end,
                                                                  E... items)
Returns a new iterator over the given array of items. The iterator is backed by the given array. The contents of the array are not modified by the iterator. The returned iterator enumerates the items located between indeces start, inclusive, and end, exclusive. If start < end, the elements are returned in the ascending order; otherwise, they are returned in the descending order.

Throws:
java.lang.NullPointerException - - items = null
java.lang.IllegalArgumentException - - start < end && (start < 0 || end > items.length) || start > end && (start >= items.length || end < -1)

emptyIterator

public static final <T> java.util.Iterator<T> emptyIterator()
Returns an iterator that has no elements. That is, calls to hasNext will return false, and all other calls will result in a runtime exception.

Returns:
an empty iterator