Class BidirectionalIterators

java.lang.Object
com.complexible.common.collect.BidirectionalIterators

public abstract class BidirectionalIterators extends Object
Utility class for bidirectional iterators.
Since:
3.0
Version:
3.0
Author:
Evren Sirin
  • Method Details

    • emptyIterator

      public static <T> BidirectionalIterator<T> emptyIterator()
      Returns an empty bidirectional iterator.
    • singletonIterator

      public static <T> BidirectionalIterator<T> singletonIterator(T theElement)
      Returns a bidirectional iterator with a single element.
    • forArray

      public static <T> BidirectionalIterator<T> forArray(T... theElements)
      Returns a bidirectional iterator containing the elements of array in order. The returned iterator is a view of the array; subsequent changes to the array will be reflected in the iterator.
    • forArray

      public static <T> BidirectionalIterator<T> forArray(T[] theElements, int theOffset, int theLimit)
      Returns a bidirectional iterator containing the elements of array in order that will iterate beginning at theOffset (inclusive) until theLimit (exclusive). The returned iterator is a view of the array; subsequent changes to the array will be reflected in the iterator.
    • forList

      public static <T> BidirectionalIterator<T> forList(List<T> theElements)
      Returns a bidirectional iterator containing the elements of list in order. The returned iterator is not fail-safe and results when the list is concurrently modified is undefined.
    • concat

      public static <T> BidirectionalIterator<T> concat(BidirectionalIterator<? extends T>... theIterators)
      Returns a bidirectional iterator that is the concatenation of theIterators.
    • concat

      public static <T> BidirectionalIterator<T> concat(Iterable<? extends BidirectionalIterator<? extends T>> theIterators)
      Returns a bidirectional iterator that is the concatenation of theIterators.
    • concat

      public static <T> BidirectionalIterator<T> concat(Iterator<? extends BidirectionalIterator<? extends T>> theIterators)
      Returns a bidirectional iterator that is the concatenation of theIterators.
    • rest

      public static <T> BidirectionalIterator<T> rest(BidirectionalIterator<T> theIterator)
      Returns a bidirectional iterator that returns the remaining elements of theIterator without allowing to go back in the iteration. More accurately, the returned iterator will no allow more previous() calls then next() calls even if theIterator has previous elements. Therefore, if theIterator is advanced (forward or backward) outside the returned iterator then the behavior will change.

      If theIterator.hasPrevious() is false then the theIterator itself will be returned.