de.caff.generics

## Interface PrimitiveLongIterable

- All Superinterfaces:
    java.lang.Iterable<java.lang.Long>
  All Known Subinterfaces:
    ExpandableLongIndexable, LongIndexable, MutableLongIndexable
  All Known Implementing Classes:
    LongIndexable.Base, LongPair, MutableLongIndexable.Base

      public interface PrimitiveLongIterable
      extends java.lang.Iterable<java.lang.Long>

  Iterable which iterates over a primitive long.
  Since:
    December 13, 2021
  Author:
    Rammi
  See Also:
    `for creating one on the fly`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static PrimitiveLongIterable` | `EMPTY` Empty iterable of primitive long values.
    `static java.util.PrimitiveIterator.OfLong` | `EMPTY_LONG_ITERATOR` Empty iterator of primitive long values.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default java.util.OptionalDouble` | `average()` Calculate the average of all elements in this iterable.
    `default boolean` | `containsLong(long value)` Does this long iterable contain the given value?
    `default void` | `forEachLong(java.util.function.LongConsumer action)` Invoke the given action with each long value in this iterable.
    `default <E extends java.lang.Exception> void` | `forEachLongFragile(FragileLongConsumer<E> action)` Invoke the given fragile action with each value in this iterable.
    `default java.util.Iterator<java.lang.Long>` | `iterator()`
    `java.util.PrimitiveIterator.OfLong` | `longIterator()` Get a primitive long iterator.
    `default java.util.Spliterator.OfLong` | `spliterator()`
    `default java.util.stream.LongStream` | `stream()` Get a stream of primitive long values from this iterable.
    `default long` | `sum()` Calculate the sum of the elements of this iterable as a long value.
    `default long` | `sumX()` Calculate the sum of the elements of this iterable as a long value.

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Field Detail

    - #### EMPTY_LONG_ITERATOR

          static final java.util.PrimitiveIterator.OfLong EMPTY_LONG_ITERATOR

      Empty iterator of primitive long values.

    - #### EMPTY

          static final PrimitiveLongIterable EMPTY

      Empty iterable of primitive long values.

  - ### Method Detail

    - #### longIterator

          @NotNull
          java.util.PrimitiveIterator.OfLong longIterator()

      Get a primitive long iterator.
      Returns:
        long iterator

    - #### iterator

          @NotNull
          default java.util.Iterator<java.lang.Long> iterator()

      Specified by:
        `iterator` in interface `java.lang.Iterable<java.lang.Long>`

    - #### forEachLong

          default void forEachLong(@NotNull
                                   java.util.function.LongConsumer action)

      Invoke the given action with each long value in this iterable.
      Parameters:
        `action` - action to be call for each long value in sequemce.

    - #### forEachLongFragile

          default <E extends java.lang.Exception> void forEachLongFragile(@NotNull
                                                                          FragileLongConsumer<E> action)
                                                                   throws E extends java.lang.Exception

      Invoke the given fragile action with each value in this iterable.
      Type Parameters:
        `E` - checked exception thrown by action
      Parameters:
        `action` - action to be called for each value in sequence
      Throws:
        `E` - if `action` throws it
        `E extends java.lang.Exception`

    - #### containsLong

          default boolean containsLong(long value)

      Does this long iterable contain the given value? This is an operation which takes time linear to the size of this iterable and should only be used rarely.
      Parameters:
        `value` - value to check for
      Returns:
        `true` if the value is contained in this iterable, `false` if not

    - #### sum

          default long sum()

      Calculate the sum of the elements of this iterable as a long value. Please note that this might silently overflow.
      Returns:
        sum of all elements of this iterable

    - #### sumX

          default long sumX()

      Calculate the sum of the elements of this iterable as a long value. This will throw an exception if summing up overflows the range of `long`.
      Returns:
        sum of all elements of this iterable

    - #### average

          @NotNull
          default java.util.OptionalDouble average()

      Calculate the average of all elements in this iterable.
      Returns:
        average, possibly `Double.NaN` if this iterable is empts

    - #### spliterator

          default java.util.Spliterator.OfLong spliterator()

      Specified by:
        `spliterator` in interface `java.lang.Iterable<java.lang.Long>`

    - #### stream

          @NotNull
          default java.util.stream.LongStream stream()

      Get a stream of primitive long values from this iterable.
      Returns:
        `long` stream