Package com.complexible.common.collect
Class BidirectionalIterators
- java.lang.Object
-
- com.complexible.common.collect.BidirectionalIterators
-
public abstract class BidirectionalIterators extends java.lang.Object
Utility class for bidirectional iterators.- Since:
- 3.0
- Version:
- 3.0
- Author:
- Evren Sirin
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> BidirectionalIterator<T>
concat(BidirectionalIterator<? extends T>... theIterators)
Returns a bidirectional iterator that is the concatenation oftheIterators
.static <T> BidirectionalIterator<T>
concat(java.lang.Iterable<? extends BidirectionalIterator<? extends T>> theIterators)
Returns a bidirectional iterator that is the concatenation oftheIterators
.static <T> BidirectionalIterator<T>
concat(java.util.Iterator<? extends BidirectionalIterator<? extends T>> theIterators)
Returns a bidirectional iterator that is the concatenation oftheIterators
.static <T> BidirectionalIterator<T>
emptyIterator()
Returns an empty bidirectional iterator.static <T> BidirectionalIterator<T>
forArray(T... theElements)
Returns a bidirectional iterator containing the elements ofarray
in order.static <T> BidirectionalIterator<T>
forArray(T[] theElements, int theOffset, int theLimit)
Returns a bidirectional iterator containing the elements ofarray
in order that will iterate beginning attheOffset
(inclusive) untiltheLimit
(exclusive).static <T> BidirectionalIterator<T>
forList(java.util.List<T> theElements)
Returns a bidirectional iterator containing the elements oflist
in order.static <T> BidirectionalIterator<T>
rest(BidirectionalIterator<T> theIterator)
Returns a bidirectional iterator that returns the remaining elements oftheIterator
without allowing to go back in the iteration.static <T> BidirectionalIterator<T>
singletonIterator(T theElement)
Returns a bidirectional iterator with a single element.
-
-
-
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 ofarray
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 ofarray
in 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
public static <T> BidirectionalIterator<T> forList(java.util.List<T> theElements)
Returns a bidirectional iterator containing the elements oflist
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 oftheIterators
.
-
concat
public static <T> BidirectionalIterator<T> concat(java.lang.Iterable<? extends BidirectionalIterator<? extends T>> theIterators)
Returns a bidirectional iterator that is the concatenation oftheIterators
.
-
concat
public static <T> BidirectionalIterator<T> concat(java.util.Iterator<? extends BidirectionalIterator<? extends T>> theIterators)
Returns a bidirectional iterator that is the concatenation oftheIterators
.
-
rest
public static <T> BidirectionalIterator<T> rest(BidirectionalIterator<T> theIterator)
Returns a bidirectional iterator that returns the remaining elements oftheIterator
without allowing to go back in the iteration. More accurately, the returned iterator will no allow moreprevious()
calls thennext()
calls even iftheIterator
has previous elements. Therefore, iftheIterator
is advanced (forward or backward) outside the returned iterator then the behavior will change.If
theIterator.hasPrevious()
is false then thetheIterator
itself will be returned.
-
-