Package com.complexible.common.collect
Class BidirectionalIterators
java.lang.Object
com.complexible.common.collect.BidirectionalIterators
Utility class for bidirectional iterators.
- Since:
- 3.0
- Version:
- 3.0
- Author:
- Evren Sirin
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> BidirectionalIterator<T> concat(BidirectionalIterator<? extends T>... theIterators) Returns a bidirectional iterator that is the concatenation oftheIterators.static <T> BidirectionalIterator<T> concat(Iterable<? extends BidirectionalIterator<? extends T>> theIterators) Returns a bidirectional iterator that is the concatenation oftheIterators.static <T> BidirectionalIterator<T> concat(Iterator<? extends BidirectionalIterator<? extends T>> theIterators) Returns a bidirectional iterator that is the concatenation oftheIterators.static <T> BidirectionalIterator<T> Returns an empty bidirectional iterator.static <T> BidirectionalIterator<T> forArray(T... theElements) Returns a bidirectional iterator containing the elements ofarrayin order.static <T> BidirectionalIterator<T> forArray(T[] theElements, int theOffset, int theLimit) Returns a bidirectional iterator containing the elements ofarrayin order that will iterate beginning attheOffset(inclusive) untiltheLimit(exclusive).static <T> BidirectionalIterator<T> Returns a bidirectional iterator containing the elements oflistin order.static <T> BidirectionalIterator<T> rest(BidirectionalIterator<T> theIterator) Returns a bidirectional iterator that returns the remaining elements oftheIteratorwithout allowing to go back in the iteration.static <T> BidirectionalIterator<T> singletonIterator(T theElement) Returns a bidirectional iterator with a single element.
-
Method Details
-
emptyIterator
Returns an empty bidirectional iterator. -
singletonIterator
Returns a bidirectional iterator with a single element. -
forArray
Returns a bidirectional iterator containing the elements ofarrayin order. The returned iterator is a view of the array; subsequent changes to the array will be reflected in the iterator. -
forArray
Returns a bidirectional iterator containing the elements ofarrayin order that will iterate beginning attheOffset(inclusive) untiltheLimit(exclusive). The returned iterator is a view of the array; subsequent changes to the array will be reflected in the iterator. -
forList
Returns a bidirectional iterator containing the elements oflistin 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 oftheIterators. -
concat
public static <T> BidirectionalIterator<T> concat(Iterable<? extends BidirectionalIterator<? extends T>> theIterators) Returns a bidirectional iterator that is the concatenation oftheIterators. -
concat
public static <T> BidirectionalIterator<T> concat(Iterator<? extends BidirectionalIterator<? extends T>> theIterators) Returns a bidirectional iterator that is the concatenation oftheIterators. -
rest
Returns a bidirectional iterator that returns the remaining elements oftheIteratorwithout allowing to go back in the iteration. More accurately, the returned iterator will no allow moreprevious()calls thennext()calls even iftheIteratorhas previous elements. Therefore, iftheIteratoris advanced (forward or backward) outside the returned iterator then the behavior will change.If
theIterator.hasPrevious()is false then thetheIteratoritself will be returned.
-