Class IteratorHelper

    • Method Detail

      • getSize

        @Nonnegative
        public static int getSize​(@Nullable
                                  IIterableIterator<?> aIterator)
        Retrieve the size of the passed Iterable.
        Parameters:
        aIterator - Iterable iterator to check. May be null.
        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 passed Iterator.
        Parameters:
        aIterator - Iterator to check. May be null.
        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 passed Enumeration.
        Parameters:
        aEnumeration - Enumeration to check. May be null.
        Returns:
        The number objects or 0 if the passed parameter is null.
      • 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 be null.
        aIter2 - Second iterator. May be null.
        Returns:
        The merged iterator. Never null.
      • getEnumeration

        @Nonnull
        public static <ELEMENTTYPE> Enumeration<ELEMENTTYPE> getEnumeration​(@Nullable
                                                                            Iterable<ELEMENTTYPE> aCont)
        Get an Enumeration object based on a Collection object.
        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 an Enumeration object 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 type
        VALUETYPE - map value type
        Parameters:
        aMap - map object to use
        Returns:
        an Enumeration object