Class BidirectionalIterators


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

      • 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​(java.util.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​(java.lang.Iterable<? extends BidirectionalIterator<? extends T>> theIterators)
        Returns a bidirectional iterator that is the concatenation of theIterators.
      • concat

        public static <T> BidirectionalIterator<T> concat​(java.util.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.