de.caff.generics.range

## Class Range

- java.lang.Object
- - de.caff.generics.range.Range

-     public class Range
      extends java.lang.Object

  Static class for providing ranges.
  Since:
    March 02, 2020
  Author:
    Rammi

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static PrimitiveIntIterable` | `indexes(java.util.Collection<?> list)` Return the range of indexes for accessing the given list.
    `static PrimitiveIntIterable` | `indexes(int length)` Return indexes for accessing an array or `java.util.List`.
    `static PrimitiveIntIterable` | `indexes(java.lang.Object[] array)` Return the range of indexes for accessing the given array.
    `static PrimitiveIntIterable` | `indexes(Sizeable s)` Return the range of indexes for accessing a sizeable object using standard indexing.
    `static PrimitiveIntIterable` | `of(int start, int end)` Get a range of integer numbers.
    `static PrimitiveIntIterable` | `of(int start, int end, int step)` Get a range of integer numbers.
    `static PrimitiveLongIterable` | `of(long start, long end)` Get a range of long integer numbers.
    `static PrimitiveLongIterable` | `of(long start, long end, long step)` Get a range of long integer numbers.

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

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

- - ### Method Detail

    - #### of

          @NotNull
          public static PrimitiveIntIterable of(int start,
                                                         int end,
                                                         int step)

      Get a range of integer numbers. The returned range will return a sequence of numbers starting with `start`, adding `step` on each iteration until either `end` is reached or the following step would reach beyond `end` (depending on step).

      So `of(1, 4, 1)` would return `1, 2, 3, 4)`, and `of(1, 4, 2`} would return `1, 3`.

      Parameters:
        `start` - start value of range (included)
        `end` - end value of range (possibly included depending on `step`). Has to be the same or larger if `step` is positive, and same or smaller of `step` is negative
        `step` - step size, must not be `0`
      Returns:
        lazy iterable of the given range
      Throws:
        `java.lang.IllegalArgumentException` - if `step` is `0` or `start`, `end` and `step` do not match

    - #### of

          @NotNull
          public static PrimitiveIntIterable of(int start,
                                                         int end)

      Get a range of integer numbers. The returned range will return a sequence of numbers starting with `start`, and a step width of either `1` (if `end >= start) or {@code -1} (if {@code end < start}`.
      Parameters:
        `start` - start value of range (included)
        `end` - end value of range (included)
      Returns:
        lazy iterable of the given range

    - #### of

          @NotNull
          public static PrimitiveLongIterable of(long start,
                                                          long end,
                                                          long step)

      Get a range of long integer numbers. The returned range will return a sequence of numbers starting with `start`, adding `step` on each iteration until either `end` is reached or the following step would reach beyond `end` (depending on step).

      So `of(1L, 4L, 1L)` would return `1L, 2L, 3L, 4L)`, and `of(1L, 4L, 2L`} would return `1L, 3L`.

      Parameters:
        `start` - start value of range (included)
        `end` - end value of range (possibly included depending on `step`). Has to be the same or larger if `step` is positive, and same or smaller of `step` is negative
        `step` - step size, must not be `0`
      Returns:
        lazy iterable of the given range
      Throws:
        `java.lang.IllegalArgumentException` - if `step` is `0` or `start`, `end` and `step` do not match

    - #### of

          @NotNull
          public static PrimitiveLongIterable of(long start,
                                                          long end)

      Get a range of long integer numbers. The returned range will provide a sequence of numbers starting with `start`, and a step width of either `1L` (if `end >= start) or {@code -1L} (if {@code end < start}`.
      Parameters:
        `start` - start value of range (included)
        `end` - end value of range (included)
      Returns:
        lazy iterable of the given range

    - #### indexes

          @NotNull
          public static PrimitiveIntIterable indexes(int length)

      Return indexes for accessing an array or `java.util.List`.
      Parameters:
        `length` - length/size of the array/list
      Returns:
        range of indexes
      Throws:
        `java.lang.IllegalArgumentException` - if `length` is negative
      See Also:
        `for an alternative`

    - #### indexes

          @NotNull
          public static PrimitiveIntIterable indexes(@NotNull
                                                              java.lang.Object[] array)

      Return the range of indexes for accessing the given array.
      Parameters:
        `array` - array
      Returns:
        range of indexes

    - #### indexes

          @NotNull
          public static PrimitiveIntIterable indexes(@NotNull
                                                              java.util.Collection<?> list)

      Return the range of indexes for accessing the given list.
      Parameters:
        `list` - list
      Returns:
        range of indexes

    - #### indexes

          @NotNull
          public static PrimitiveIntIterable indexes(@NotNull
                                                              Sizeable s)

      Return the range of indexes for accessing a sizeable object using standard indexing.
      Parameters:
        `s` - sizeable object
      Returns:
        range of indexes