Package com.helger.commons.collection
Class IteratorHelper
- java.lang.Object
-
- com.helger.commons.collection.IteratorHelper
-
public final class IteratorHelper extends Object
- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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 intgetSize(Iterator<?> aIterator)Retrieve the size of the passedIterator.static booleanisEmpty(IIterableIterator<?> aIter)static booleanisEmpty(Enumeration<?> aEnum)static booleanisEmpty(Iterator<?> aIter)static booleanisNotEmpty(IIterableIterator<?> aIter)static booleanisNotEmpty(Enumeration<?> aEnum)static booleanisNotEmpty(Iterator<?> aIter)
-
-
-
Method Detail
-
isEmpty
public static boolean isEmpty(@Nullable IIterableIterator<?> aIter)
-
isEmpty
public static boolean isEmpty(@Nullable Enumeration<?> aEnum)
-
isNotEmpty
public static boolean isNotEmpty(@Nullable IIterableIterator<?> aIter)
-
isNotEmpty
public static boolean isNotEmpty(@Nullable Enumeration<?> aEnum)
-
getSize
@Nonnegative public static int getSize(@Nullable IIterableIterator<?> aIterator)
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
@Nonnegative public static int getSize(@Nullable Iterator<?> aIterator)
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
@Nonnegative public static int getSize(@Nullable Enumeration<?> aEnumeration)
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
@Nonnull public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getIterator(@Nullable Iterable<ELEMENTTYPE> aCont)
-
getIterator
@Nonnull public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getIterator(@Nullable Iterator<ELEMENTTYPE> aIter)
-
getIterator
@Nonnull @SafeVarargs public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getIterator(@Nullable ELEMENTTYPE... aArray)
-
getReverseIterator
@Nonnull public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getReverseIterator(@Nullable List<? extends ELEMENTTYPE> aCont)
-
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
-
-