Class IntRange

    • Method Detail

      • min

        public int min()
        Return the minimum value of the integer range.
        Returns:
        the minimum value of the integer range
      • max

        public int max()
        Return the maximum value of the integer range.
        Returns:
        the maximum value of the integer range
      • size

        public int size()
        Return the size of the IntRange: max - min.
        Returns:
        the size of the int range
        Since:
        3.9
      • stream

        public IntStream stream()
        Returns a sequential ordered IntStream from min() (inclusive) to max() (exclusive) by an incremental step of 1.

        An equivalent sequence of increasing values can be produced sequentially using a for loop as follows:

        for (int i = range.min(); i < range.max(); ++i) { ... }
        Returns:
        a sequential IntStream for the range of int elements
        Since:
        3.4
      • of

        public static IntRange of​(int min,
                                  int max)
        Create a new IntRange object with the given min and max values.
        Parameters:
        min - the lower bound of the integer range
        max - the upper bound of the integer range
        Returns:
        a new IntRange object
        Throws:
        IllegalArgumentException - if min > max
      • of

        public static IntRange of​(int value)
        Return a new (half open) range, which contains only the given value: [value, value + 1).
        Parameters:
        value - the value of the created (half open) integer range
        Returns:
        a new (half open) range, which contains only the given value
        Since:
        4.0