Package com.helger.commons.collection
Class IteratorHelper
java.lang.Object
com.helger.commons.collection.IteratorHelper
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionstatic <ELEMENTTYPE>
Iterator<ELEMENTTYPE> getCombinedIterator(Iterator<? extends ELEMENTTYPE> aIter1, Iterator<? extends ELEMENTTYPE> aIter2) Get a merged iterator of both iterators.static <ELEMENTTYPE>
Enumeration<ELEMENTTYPE> getEnumeration(ELEMENTTYPE... aArray) Get anEnumerationobject based on the passed array.static <ELEMENTTYPE>
Enumeration<ELEMENTTYPE> getEnumeration(Iterable<ELEMENTTYPE> aCont) Get anEnumerationobject based on aCollectionobject.static <ELEMENTTYPE>
Enumeration<ELEMENTTYPE> getEnumeration(Iterator<ELEMENTTYPE> aIter) Get an Enumeration object based on an Iterator object.static <KEYTYPE,VALUETYPE>
Enumeration<Map.Entry<KEYTYPE, VALUETYPE>> getEnumeration(Map<KEYTYPE, VALUETYPE> aMap) Get an Enumeration object based on a Map object.static <ELEMENTTYPE>
Iterator<ELEMENTTYPE> getIterator(ELEMENTTYPE... aArray) static <ELEMENTTYPE>
Iterator<ELEMENTTYPE> getIterator(Iterable<ELEMENTTYPE> aCont) static <ELEMENTTYPE>
IIterableIterator<ELEMENTTYPE> getIterator(Enumeration<? extends ELEMENTTYPE> aEnum) static <ELEMENTTYPE>
Iterator<ELEMENTTYPE> getIterator(Iterator<ELEMENTTYPE> aIter) static <ELEMENTTYPE>
Iterator<ELEMENTTYPE> getReverseIterator(List<? extends ELEMENTTYPE> aCont) static intgetSize(IIterableIterator<?> aIterator) Retrieve the size of the passedIterable.static intgetSize(Enumeration<?> aEnumeration) Retrieve the size of the passedEnumeration.static intRetrieve the size of the passedIterator.static booleanisEmpty(IIterableIterator<?> aIter) static booleanisEmpty(Enumeration<?> aEnum) static booleanstatic booleanisNotEmpty(IIterableIterator<?> aIter) static booleanisNotEmpty(Enumeration<?> aEnum) static booleanisNotEmpty(Iterator<?> aIter)
-
Method Details
-
isEmpty
-
isEmpty
-
isEmpty
-
isNotEmpty
-
isNotEmpty
-
isNotEmpty
-
getSize
Retrieve the size of the passedIterable.- Parameters:
aIterator- Iterable iterator to check. May benull.- Returns:
- The number objects or 0 if the passed parameter is
null.
-
getSize
Retrieve the size of the passedIterator.- Parameters:
aIterator- Iterator to check. May benull.- Returns:
- The number objects or 0 if the passed parameter is
null.
-
getSize
Retrieve the size of the passedEnumeration.- Parameters:
aEnumeration- Enumeration to check. May benull.- Returns:
- The number objects or 0 if the passed parameter is
null.
-
getIterator
@Nonnull public static <ELEMENTTYPE> IIterableIterator<ELEMENTTYPE> getIterator(@Nullable Enumeration<? extends ELEMENTTYPE> aEnum) -
getIterator
-
getIterator
-
getIterator
@Nonnull @SafeVarargs public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getIterator(@Nullable ELEMENTTYPE... aArray) -
getReverseIterator
-
getCombinedIterator
@Nonnull public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getCombinedIterator(@Nullable Iterator<? extends ELEMENTTYPE> aIter1, @Nullable Iterator<? extends ELEMENTTYPE> aIter2) Get a merged iterator of both iterators. The first iterator is iterated first, the second one afterwards.- Type Parameters:
ELEMENTTYPE- The type of elements to be enumerated.- Parameters:
aIter1- First iterator. May benull.aIter2- Second iterator. May benull.- Returns:
- The merged iterator. Never
null.
-
getEnumeration
@Nonnull public static <ELEMENTTYPE> Enumeration<ELEMENTTYPE> getEnumeration(@Nullable Iterable<ELEMENTTYPE> aCont) Get anEnumerationobject based on aCollectionobject.- Type Parameters:
ELEMENTTYPE- the type of the elements in the container- Parameters:
aCont- The container to enumerate.- Returns:
- an Enumeration object
-
getEnumeration
@Nonnull @SafeVarargs public static <ELEMENTTYPE> Enumeration<ELEMENTTYPE> getEnumeration(@Nullable ELEMENTTYPE... aArray) Get anEnumerationobject based on the passed array.- Type Parameters:
ELEMENTTYPE- the type of the elements in the container- Parameters:
aArray- The array to enumerate.- Returns:
- an Enumeration object
-
getEnumeration
@Nonnull public static <ELEMENTTYPE> Enumeration<ELEMENTTYPE> getEnumeration(@Nullable Iterator<ELEMENTTYPE> aIter) Get an Enumeration object based on an Iterator object.- Type Parameters:
ELEMENTTYPE- the type of the elements in the container- Parameters:
aIter- iterator object to use- Returns:
- an Enumeration object
-
getEnumeration
@Nonnull public static <KEYTYPE,VALUETYPE> Enumeration<Map.Entry<KEYTYPE,VALUETYPE>> getEnumeration(@Nullable Map<KEYTYPE, VALUETYPE> aMap) Get an Enumeration object based on a Map object.- Type Parameters:
KEYTYPE- map key typeVALUETYPE- map value type- Parameters:
aMap- map object to use- Returns:
- an Enumeration object
-