de.caff.generics

## Class TypesImplFolding

- java.lang.Object
- - de.caff.generics.TypesImplFolding

-     final class TypesImplFolding
      extends java.lang.Object

  Partial class used by Types, defining the folding algorithms.
  Author:
    Rammi

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <V,T> V` | `foldLeftImpl(java.util.Enumeration<T> enumeration, V initialValue, java.util.function.BiFunction<? super V,? super T,? extends V> folder)` Do left-associative folding of an enumeration.
    `static <V,T> V` | `foldLeftImpl(java.util.Iterator<T> iterator, V initialValue, java.util.function.BiFunction<? super V,? super T,? extends V> folder)` Do left-associative folding of an iterator.
    `static <V,T> V` | `foldRightImpl(java.util.List<T> list, V initialValue, java.util.function.BiFunction<? super V,? super T,? extends V> folder)` Do right-associative folding of an iteration.
    `static <V,T> V` | `foldRightImpl(java.util.ListIterator<T> reverseIterator, V initialValue, java.util.function.BiFunction<? super V,? super T,? extends V> folder)` Do right-associative folding of a list iterator using it in reverse direction.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### foldLeftImpl

          public static <V,T> V foldLeftImpl(@NotNull
                                             java.util.Iterator<T> iterator,
                                             V initialValue,
                                             @NotNull
                                             java.util.function.BiFunction<? super V,? super T,? extends V> folder)

      Do left-associative folding of an iterator.

      Folding is the reduction of the elements of a collection into one value, by applying the same function on each element with the result of the last call.

      See `Types.foldLeft(Iterable, Object, BiFunction)` for a code example.

      Type Parameters:
        `V` - accumulated value type
        `T` - iterable type
      Parameters:
        `iterator` - iterator which elements are folded together
        `initialValue` - start value
        `folder` - folding function, the apply method gets the accumulated value as its first and the element as its second argument, and returns the result of their combination
      Returns:
        accumulated value

    - #### foldLeftImpl

          public static <V,T> V foldLeftImpl(@NotNull
                                             java.util.Enumeration<T> enumeration,
                                             V initialValue,
                                             @NotNull
                                             java.util.function.BiFunction<? super V,? super T,? extends V> folder)

      Do left-associative folding of an enumeration.

      Folding is the reduction of the elements of a collection into one value, by applying the same function on each element with the result of the last call.

      See `Types.foldLeft(Iterable, Object, BiFunction)` for a code example.

      Type Parameters:
        `V` - accumulated value type
        `T` - iterable type
      Parameters:
        `enumeration` - enumeration which elements are folded together
        `initialValue` - start value
        `folder` - folding function, the apply method gets the accumulated value as its first and the element as its second argument, and returns the result of their combination
      Returns:
        accumulated value

    - #### foldRightImpl

          public static <V,T> V foldRightImpl(@NotNull
                                              java.util.List<T> list,
                                              V initialValue,
                                              @NotNull
                                              java.util.function.BiFunction<? super V,? super T,? extends V> folder)

      Do right-associative folding of an iteration.

      Folding is the reduction of the elements of a collection into one value, by applying the same function on each element with the result of the last call.

      Type Parameters:
        `V` - accumulated value type
        `T` - iterator type
      Parameters:
        `list` - list which elements are folded together
        `initialValue` - start value
        `folder` - folding function, the apply method gets the accumulated value as its first and the element as its second argument, and returns the result of their combination
      Returns:
        accumulated value

    - #### foldRightImpl

          public static <V,T> V foldRightImpl(@NotNull
                                              java.util.ListIterator<T> reverseIterator,
                                              V initialValue,
                                              @NotNull
                                              java.util.function.BiFunction<? super V,? super T,? extends V> folder)

      Do right-associative folding of a list iterator using it in reverse direction.

      Folding is the reduction of the elements of a collection into one value, by applying the same function on each element with the result of the last call.

      Type Parameters:
        `V` - accumulated value type
        `T` - list type
      Parameters:
        `reverseIterator` - iterator which is traverse in reverse direction
        `initialValue` - start value
        `folder` - folding function, the apply method gets the accumulated value as its first and the element as its second argument, and returns the result of their combination
      Returns:
        accumulated value