|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.structure.iterator.IteratorUtils
public class IteratorUtils
Helper related to Iterator
IterableUtils| Constructor Summary | |
|---|---|
IteratorUtils()
|
|
| Method Summary | ||
|---|---|---|
static
|
adapter(ElementStream<E> elementStream)
Returns an Iterator adapter on a given ElementStream |
|
static
|
adapter(Iterator<? extends FROM> iterator,
ElementConverter<FROM,TO> elementConverter)
Returns a new decorator instance of the given Iterator which uses the given ElementConverter to convert the
result of the Iterator.next() method. |
|
static
|
adapter(Iterator<FROM> iterator,
ElementConverter<FROM,? extends T> elementConverterFirst,
ElementConverter<T,? extends TO> elementConverterSecond)
Similar to adapter(Iterator, ElementConverter) |
|
static
|
adapter(Iterator<FROM> iterator,
ElementConverter<FROM,? extends T1> elementConverterFirst,
ElementConverter<T1,? extends T2> elementConverterSecond,
ElementConverter<T2,? extends TO> elementConverterThird)
Similar to adapter(Iterator, ElementConverter) |
|
static
|
addToNewIterator(Iterator<E> iterator,
E... elements)
Returns a new Iterator instance which contains all elements from the given Iterator and the additional given
elements. |
|
static
|
chained(Collection<? extends Iterator<E>> iterators)
Similar to chained(Iterator...) |
|
static
|
chained(Iterator<E>... iterators)
Returns an Iterator wrapper which chains the given Iterator instances. |
|
static
|
drainTo(Iterator<E> iterator,
Collection<E> collection)
Drains the given Iterator to the given Collection This invokes the Iterator.remove() method for every element drained. |
|
static
|
drainTo(Iterator<E> iterator,
Collection<E> collection,
int maxNumberOfElements)
Drains the given Iterator by the given maximum number of elements to the given Collection. |
|
static
|
empty()
Returns an empty Iterator |
|
static
|
factoryBasedIterator(Factory<Iterator<E>> iteratorFactory)
Returns a new Iterator instance which will iterate over all Iterator instances created by the given
Factory. |
|
static
|
filtered(Iterator<E> iterator,
BitSet filter)
Returns an Iterator which returns a filtered subset of the given Iterator based on the given filter
BitSet |
|
static
|
limitingIteratorDecorator(Iterator<E> iterator,
int limit)
Returns a new decorator instance wrapping the given Iterator which will limit the elements which can be retrieved to
the given number |
|
static
|
lockedByReentrantLockIterator(Iterator<E> iterator)
Returns a view on the given Iterator which uses a ReentrantLock to synchronize all its methods. |
|
static
|
lockedIterator(Iterator<E> iterator,
Lock lock)
Returns a view on the given Iterator which uses a Lock to synchronize all its methods. |
|
static
|
merge(Iterator<E>... iterators)
Merges all elements immediately into a single and new Iterator instance. |
|
static
|
roundRobin(Iterator<E>... iterators)
Returns an Iterator which calls Iterator.next() of all given Iterators in a round robin way |
|
static int |
size(Iterator<?> iterator)
Resolves the size of a given Iterator by iterating over it. |
|
static
|
threadLocalCachedIterator(Iterator<E> iterator)
Returns a view on the given Iterator which uses a ThreadLocal instance to cache resolved elements per
Thread. |
|
static
|
valueOf(E... elements)
Returns an Iterator instance for the given elements |
|
static
|
valueOf(Iterable<E>... iterables)
Returns the Iterator instances of the given Iterables. |
|
static
|
valueOf(List<E>... lists)
Returns the ListIterator instances of the given Lists. |
|
static
|
valueOfMultiple(Iterable<E>... iterables)
Returns a List of the Iterators related to the given Iterables |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IteratorUtils()
| Method Detail |
|---|
public static int size(Iterator<?> iterator)
Iterator by iterating over it.
iterator -
public static <E> Iterator<E> lockedIterator(Iterator<E> iterator,
Lock lock)
Iterator which uses a Lock to synchronize all its methods.
iterator - lock -
public static <E> Iterator<E> threadLocalCachedIterator(Iterator<E> iterator)
Iterator which uses a ThreadLocal instance to cache resolved elements per
Thread. The underlying Iterator will by locked to be usable by multiple threads.
iterator -
lockedIterator(Iterator, Lock),
ThreadLocalCachedIteratorpublic static <E> Iterator<E> lockedByReentrantLockIterator(Iterator<E> iterator)
Iterator which uses a ReentrantLock to synchronize all its methods.
iterator -
public static <E> Iterator<E> factoryBasedIterator(Factory<Iterator<E>> iteratorFactory)
Iterator instance which will iterate over all Iterator instances created by the given
Factory. If the Factory.newInstance() returns null, the Iterator ends.
iteratorFactory -
public static <E> Iterator<E> merge(Iterator<E>... iterators)
Iterator instance.Iterator instances will be traversed after calling this method.
iterators -
chained(Iterator...)
public static <E> Iterator<E> addToNewIterator(Iterator<E> iterator,
E... elements)
Iterator instance which contains all elements from the given Iterator and the additional given
elements. Iterator instances will be traversed after calling this method.
iterator - elements -
chained(Iterator...)public static <E> Iterator<E> chained(Iterator<E>... iterators)
Iterator wrapper which chains the given Iterator instances. The single Iterator instances
will only executed when the returned wrapper iterator points to them.
iterators -
merge(Iterator...)public static <E> Iterator<E> chained(Collection<? extends Iterator<E>> iterators)
chained(Iterator...)
iterators -
public static <E> Iterator<E> roundRobin(Iterator<E>... iterators)
Iterator which calls Iterator.next() of all given Iterators in a round robin way
iterators -
public static <E> Iterator<E>[] valueOfMultiple(Iterable<E>... iterables)
List of the Iterators related to the given Iterables
iterables -
public static <TO,FROM> Iterator<TO> adapter(Iterator<? extends FROM> iterator,
ElementConverter<FROM,TO> elementConverter)
Iterator which uses the given ElementConverter to convert the
result of the Iterator.next() method. ElementConverter or Iterator is null, this method return null.
iterator - elementConverter -
public static <TO,FROM,T> Iterator<TO> adapter(Iterator<FROM> iterator,
ElementConverter<FROM,? extends T> elementConverterFirst,
ElementConverter<T,? extends TO> elementConverterSecond)
adapter(Iterator, ElementConverter)
iterator - elementConverterFirst - elementConverterSecond -
public static <TO,FROM,T1,T2> Iterator<TO> adapter(Iterator<FROM> iterator,
ElementConverter<FROM,? extends T1> elementConverterFirst,
ElementConverter<T1,? extends T2> elementConverterSecond,
ElementConverter<T2,? extends TO> elementConverterThird)
adapter(Iterator, ElementConverter)
iterator - elementConverterFirst - elementConverterSecond - elementConverterThird -
public static <E> Iterator<E> adapter(ElementStream<E> elementStream)
Iterator adapter on a given ElementStream
elementStream -
public static <E> Iterator<E>[] valueOf(Iterable<E>... iterables)
Iterator instances of the given Iterables. If an Iterator instance is null it will not be
added to the returned array. This circumstance can lead to different array sizes.
iterables -
public static <E> ListIterator<E>[] valueOf(List<E>... lists)
ListIterator instances of the given Lists. If an ListIterator instance is null it will
not be added to the returned array. This circumstance can lead to different array sizes.
lists -
public static <E> Iterator<E> valueOf(E... elements)
Iterator instance for the given elements
elements -
Iterator
public static <E> void drainTo(Iterator<E> iterator,
Collection<E> collection)
Iterator to the given Collection Iterator.remove() method for every element drained.
iterator - collection -
public static <E> void drainTo(Iterator<E> iterator,
Collection<E> collection,
int maxNumberOfElements)
Iterator by the given maximum number of elements to the given Collection. Iterator.remove() method for every element drained.
iterator - collection - maxNumberOfElements -
public static <E> Iterator<E> limitingIteratorDecorator(Iterator<E> iterator,
int limit)
Iterator which will limit the elements which can be retrieved to
the given number
iterator - Iteratorlimit -
public static <E> Iterator<E> filtered(Iterator<E> iterator,
BitSet filter)
Iterator which returns a filtered subset of the given Iterator based on the given filter
BitSet
iterator - filter -
Iterator instancepublic static <E> Iterator<E> empty()
Iterator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||