Package: primitives

## [Java] Class int[]

- primitives.int[]

-     public class int[]
      extends Object

  GDK enhancements for int[].

  displayName:
    int[]
  receiverFqcn:
    int[]

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `any(Closure<?> predicate)` Iterates over the contents of an int Array, and checks whether a predicate is valid for at least one element.
    `` | `public boolean` | `asBoolean()` Coerces an int array to a boolean value.
    `` | `public BigDecimal` | `average()` Calculates the average of the ints in the array.
    `` | `public List<List<Integer>>` | `chop(int chopSizes)` Chops the int array into pieces, returning lists with sizes corresponding to the supplied chop sizes.
    `` | `public boolean` | `contains(Object value)` Checks whether the array contains the given value.
    `` | `public Number` | `count(Object value)` Counts the number of occurrences of the given value inside this array.
    `` | `public int[]` | `each(IntConsumer consumer)` Iterates through an int[] passing each int to the given consumer.
    `` | `public int[]` | `each(Closure<?> closure)` Iterates through an int[] passing each int to the given closure.
    `` | `public int[]` | `eachWithIndex(Closure<?> closure)` Iterates through an int[], passing each int and the element's index (a counter starting at zero) to the given closure.
    `` | `public boolean` | `equals(int[] right)` Compares the contents of this array to the contents of the given array.
    `` | `public boolean` | `every(Closure<?> predicate)` Iterates over the contents of an int Array, and checks whether a predicate is valid for all elements.
    `` | `public int` | `first()` Returns the first item from the int array.
    `` | `public List<Integer>` | `flatten()` Flattens an array.
    `` | `public List<Integer>` | `getAt(Range<?> range)` Supports the subscript operator for an int array with a range giving the desired indices.
    `` | `public List<Integer>` | `getAt(IntRange range)` Supports the subscript operator for an int array with an IntRange giving the desired indices.
    `` | `public List<Integer>` | `getAt(ObjectRange range)` Supports the subscript operator for an int array with an ObjectRange giving the desired indices.
    `` | `public List<Integer>` | `getAt(Collection<?> indices)` Supports the subscript operator for an int array with a (potentially nested) collection giving the desired indices.
    `` | `public IntRange` | `getIndices()` Returns indices of the int array.
    `` | `public String` | `groovyToString()` Returns Groovy's list-like string representation for an int array.
    `` | `public int` | `head()` Returns the first item from the int array.
    `` | `public Map<Integer, Integer>` | `indexed()` Zips an int[] with indices in (index, value) order starting from index 0.
    `` | `public Map<Integer, Integer>` | `indexed(int offset)` Zips an int[] with indices in (index, value) order starting from a given index.
    `` | `public int[]` | `init()` Returns the items from the int array excluding the last item.
    `` | `public IntStream` | `intStream()` Returns a sequential IntStream with the specified array as its source.
    `` | `public boolean` | `isSorted()` Determines if the array is sorted in natural (ascending) order.
    `` | `public String` | `join()` Concatenates the string representation of each item in this array.
    `` | `public String` | `join(String separator)` Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    `` | `public int` | `last()` Returns the last item from the int array.
    `` | `public int` | `max()` Adds max() method to int arrays.
    `` | `public int` | `max(IntComparator comparator)` Selects the maximum value found from the int array using the supplied IntComparator to determine the maximum of any two values.
    `` | `public int` | `max(IntUnaryOperator operator)` Selects the maximum value found from the int array using the supplied IntUnaryOperator to determine the maximum of any two values.
    `` | `public int` | `maxComparing(Comparator<Integer> comparator)` Selects the maximum value found from the int array using the comparator to determine the maximum of any two values.
    `` | `public int` | `min()` Adds min() method to int arrays.
    `` | `public int` | `min(IntComparator comparator)` Selects the minimum value found from the int array using the supplied IntComparator to determine the minimum of any two values.
    `` | `public int` | `min(IntUnaryOperator operator)` Selects the minimum value found from the int array using the supplied IntUnaryOperator to determine the minimum of any two values.
    `` | `public int` | `minComparing(Comparator<Integer> comparator)` Selects the minimum value found from the int array using the comparator to determine the minimum of any two values.
    `` | `public int` | `partitionPoint(IntRange range, IntPredicate condition)` Returns the index of the partition point according to the given predicate (the index of the first element of the second partition).
    `` | `public int` | `partitionPoint(IntPredicate condition)` Returns the index of the partition point according to the given predicate (the index of the first element of the second partition).
    `` | `public void` | `putAt(IntRange range, int[] source)` A helper method to allow arrays to be set with subscript operators.
    `` | `public void` | `putAt(IntRange range, Iterable<Number> source)` A helper method to allow arrays to be set with subscript operators.
    `` | `public int[]` | `reverse()` Creates a new int array containing items which are the same as this array but in reverse order.
    `` | `public int[]` | `reverse(boolean mutate)` Reverses the items in an array.
    `` | `public int[]` | `reverseEach(Closure<?> closure)` Iterates through an int[] in reverse order passing each int to the given closure.
    `` | `public int` | `size()` Provides arrays with a `size` method similar to collections.
    `` | `public Stream<Integer>` | `stream()` Returns a sequential Stream with the specified array as its source.
    `` | `public int` | `sum()` Sums the items in an array.
    `` | `public int` | `sum(IntUnaryOperator operator)` Calculates the sum of values found from applying the operator to members of the int array.
    `` | `public int` | `sum(int initialValue)` Sums the items in an array, adding the result to some initial value.
    `` | `public int[]` | `swap(int i, int j)` Swaps two elements at the specified positions.
    `` | `public int[]` | `tail()` Returns the items from the int array excluding the first item.
    `` | `public List<Integer>` | `toImmutableList()` Converts this array to an immutable List of the same size, with each element added to the list.
    `` | `public Set<Integer>` | `toImmutableSet()` Converts this array to an immutable Set, with each unique element added to the set.
    `` | `public List<Integer>` | `toList()` Converts this array to a List of the same size, with each element added to the list.
    `` | `public Set<Integer>` | `toSet()` Converts this array to a Set, with each unique element added to the set.
    `` | `public String` | `toString()` Returns the string representation of the given array.
    `` | `public List<Tuple2<Integer, Integer>>` | `withIndex()` Zips an int array with indices in (value, index) order.
    `` | `public List<Tuple2<Integer, Integer>>` | `withIndex(int offset)` Zips an int array with indices in (value, index) order starting from a given index.
    `` | `public List<Tuple2<Integer, Integer>>` | `zip(int[] other)` A list of all the pairs from two arrays.
    `` | `public Iterator<Tuple2<Integer, Integer>>` | `zipping(int[] other)` An iterator of all the pairs from two arrays.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `addShutdownHook, any, any, asBoolean, asType, clamp, clamp, collect, collect, collect, dump, each, eachMatch, eachMatch, eachWithIndex, every, every, find, find, findAll, findAll, findIndexOf, findIndexOf, findIndexValues, findIndexValues, findLastIndexOf, findLastIndexOf, findResult, findResult, findResult, findResult, getAt, getMetaClass, getMetaPropertyValues, getProperties, grep, grep, hasProperty, identity, inject, inject, inspect, invokeMethod, is, isCase, isNotCase, iterator, metaClass, print, print, printf, printf, println, println, println, putAt, respondsTo, respondsTo, setMetaClass, sleep, sleep, split, sprintf, sprintf, stream, takeIf, tap, toString, use, use, use, with, with, withCloseable, withCloseable, withMethodClosure, withStream, withStream, withTraits`

- - ### Method Detail

    - #### public boolean any(Closure<?> predicate)

      Iterates over the contents of an int Array, and checks whether a predicate is valid for at least one element.

           int[] array = [0, 1, 2]
           assert array.any{ it > 1 }
           assert !array.any{ it > 3 }

      Parameters:
        `predicate` - the closure predicate used for matching
      Returns:
        true if any iteration for the ints matches the closure predicate
      Since:
        5.0.0

    - #### public boolean asBoolean()

      Coerces an int array to a boolean value. An int array is false if the array is of length 0, and true otherwise.

      Returns:
        the array's boolean value
      Since:
        1.7.4

    - #### public BigDecimal average()

      Calculates the average of the ints in the array.

          assert 5.0G == ([2,4,6,8] as int[]).average()

      Returns:
        The average of the items
      Since:
        3.0.0

    - #### public List<List<Integer>> chop(int chopSizes)

      Chops the int array into pieces, returning lists with sizes corresponding to the supplied chop sizes. If the array isn't large enough, truncated (possibly empty) pieces are returned. Using a chop size of -1 will cause that piece to contain all remaining items from the array.

           int[] array = [0, 1, 2]
           assert array.chop(1, 2) == [[0], [1, 2]]

      Parameters:
        `chopSizes` - the sizes for the returned pieces
      Returns:
        a list of lists chopping the original array elements into pieces determined by chopSizes
      See Also:
        ArrayGroovyMethods#collate(Object[], int)#collate(Object[], int)
      Since:
        5.0.0

    - #### public boolean contains(Object value)

      Checks whether the array contains the given value.

      Parameters:
        `value` - the value being searched for
      Returns:
        true if the array contains the value
      Since:
        1.8.6

    - #### public Number count(Object value)

      Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (using `compareTo(value) == 0`).

           int[] array = [10, 20, 20, 30]
           assert array.count(20) == 2

      Parameters:
        `value` - the value being searched for
      Returns:
        the number of occurrences
      See Also:
        DefaultGroovyMethods#count(Iterator, Object)#count(Iterator, Object)
      Since:
        1.6.4

    - #### public int[] each(IntConsumer consumer)

      Iterates through an int[] passing each int to the given consumer.

           int[] array = [0, 1, 2]
           String result = ''
           array.each{ result += it }
           assert result == '012'

      Parameters:
        `consumer` - the consumer for each int
      Returns:
        the self array
      Since:
        5.0.0

    - #### public int[] each(Closure<?> closure)

      Iterates through an int[] passing each int to the given closure.

           int[] array = [0, 1, 2]
           String result = ''
           array.each{ result += it }
           assert result == '012'

      Parameters:
        `closure` - the closure applied on each int
      Returns:
        the self array
      Since:
        6.0.0

    - #### public int[] eachWithIndex(Closure<?> closure)

      Iterates through an int[], passing each int and the element's index (a counter starting at zero) to the given closure.

           int[] array = [10, 20, 30]
           String result = ''
           array.eachWithIndex{ item, index -> result += "$index($item)" }
           assert result == '0(10)1(20)2(30)'

      Parameters:
        `closure` - a Closure to operate on each int
      Returns:
        the self array
      Since:
        5.0.0

    - #### public boolean equals(int[] right)

      Compares the contents of this array to the contents of the given array.

      Example usage:

           int[] array1 = [4, 8]
           int[] array2 = [4, 8]
           assert array1 !== array2
           assert array1.equals(array2)

      Parameters:
        `right` - the array being compared
      Returns:
        true if the contents of both arrays are equal.
      Since:
        5.0.0

    - #### public boolean every(Closure<?> predicate)

      Iterates over the contents of an int Array, and checks whether a predicate is valid for all elements.

           int[] array = [0, 1, 2]
           assert array.every{ it < 3 }
           assert !array.every{ it > 1 }

      Parameters:
        `predicate` - the closure predicate used for matching
      Returns:
        true if the predicate returns true for all elements in the array
      Since:
        5.0.0

    - #### public int first()

      Returns the first item from the int array.

           int[] ints = [1, 3, 5]
           assert ints.first() == 1

      An alias for `head()`.
      throws:
        NoSuchElementException if the array is empty
      Returns:
        the first element
      Since:
        5.0.0

    - #### public List<Integer> flatten()

      Flattens an array. This array is added to a new collection. It is an alias for `toList()` but allows algorithms to be written which also work on multidimensional arrays or non-arrays where flattening would be applicable.

           int[] array = [0, 1]
           assert array.flatten() == [0, 1]

      Returns:
        a Collection of the array elements
      Since:
        1.6.0

    - #### public List<Integer> getAt(Range<?> range)

      Supports the subscript operator for an int array with a range giving the desired indices.

           int[] array = [1, 3, 5, 7, 9, 11]
           assert array[2..<2] == [] // EmptyRange
           assert array[(0..5.5).step(2)] == [1, 5, 9]   // NumberRange
           assert array[(1..5.5).step(2)] == [3, 7, 11]  // NumberRange

      Parameters:
        `range` - a range indicating the indices for the items to retrieve
      Returns:
        list of the ints at the given indices
      Since:
        1.0

    - #### public List<Integer> getAt(IntRange range)

      Supports the subscript operator for an int array with an IntRange giving the desired indices.

           int[] array = [0, 10, 20, 30, 40]
           assert array[2..3] == [20, 30]
           assert array[-2..-1] == [30, 40]
           assert array[-1..-2] == [40, 30]

      Parameters:
        `range` - an IntRange indicating the indices for the items to retrieve
      Returns:
        list of the retrieved ints
      Since:
        1.0

    - #### public List<Integer> getAt(ObjectRange range)

      Supports the subscript operator for an int array with an ObjectRange giving the desired indices.

           int[] array = [0, 10, 20, 30, 40]
           def range = new ObjectRange(2, 3)
           assert array[range] == [20, 30]

      Parameters:
        `range` - an ObjectRange indicating the indices for the items to retrieve
      Returns:
        list of the retrieved ints
      Since:
        1.0

    - #### public List<Integer> getAt(Collection<?> indices)

      Supports the subscript operator for an int array with a (potentially nested) collection giving the desired indices.

           int[] array = [0, 2, 4, 6, 8]
           assert array[2, 3] == [4, 6]
           assert array[1, 0..1, [0, [-1]]] == [2, 0, 2, 0, 8]

      Parameters:
        `indices` - a collection of indices for the items to retrieve
      Returns:
        list of the ints at the given indices
      Since:
        1.0

    - #### public IntRange getIndices()

      Returns indices of the int array.

           int[] array = [0, 1]
           assert array.indices == 0..1

      See Also:
        ArrayGroovyMethods#getIndices(Object[])#getIndices(Object[])
      Since:
        3.0.8

    - #### public String groovyToString()

      Returns Groovy's list-like string representation for an int array.

      If disabled, e.g. via `-Dgroovy.extension.disable=groovyToString(int[])`, the JDK's default array `toString()` is used instead.

      Returns:
        the string representation
      Since:
        6.0.0

    - #### public int head()

      Returns the first item from the int array.

           int[] ints = [1, 3, 5]
           assert ints.head() == 1

      An alias for `first()`.
      throws:
        NoSuchElementException if the array is empty
      Returns:
        the first element
      Since:
        5.0.0

    - #### public Map<Integer, Integer> indexed()

      Zips an int[] with indices in (index, value) order starting from index 0.

      Example usage:

           int[] nums = [10, 20, 30]
           assert [0: 10, 1: 20, 2: 30] == nums.indexed()

      See Also:
        indexed(int[], int)
      Since:
        3.0.8

    - #### public Map<Integer, Integer> indexed(int offset)

      Zips an int[] with indices in (index, value) order starting from a given index.

      Example usage:

           int[] nums = [10, 20, 30]
           assert [5: 10, 6: 20, 7: 30] == nums.indexed(5)
           assert ["1: 10", "2: 20", "3: 30"] == nums.indexed(1).collect { idx, str -> "$idx: $str" }

      Parameters:
        `offset` - an index to start from
      Returns:
        a Map (since the keys/indices are unique) containing the elements from the iterable zipped with indices
      See Also:
        DefaultGroovyMethods#indexed(Iterable, int)#indexed(Iterable, int)
      Since:
        3.0.8

    - #### public int[] init()

      Returns the items from the int array excluding the last item.

           int[] ints = [1, 3, 5]
           def result = ints.init()
           assert result == [1, 3]
           assert ints.class.componentType == result.class.componentType

      throws:
        UnsupportedOperationException if the array is empty
      Returns:
        an array without its last element
      Since:
        5.0.0

    - #### public IntStream intStream()

      Returns a sequential IntStream with the specified array as its source.

      Returns:
        a `Stream` for the array
      Since:
        3.0.8

    - #### public boolean isSorted()

      Determines if the array is sorted in natural (ascending) order. This is efficient — it checks adjacent pairs in a single pass and short-circuits on the first out-of-order pair.

           int[] nums = [1, 2, 3]
           assert nums.isSorted()
           int[] unsorted = [3, 1, 2]
           assert !unsorted.isSorted()

      Returns:
        true if the array elements are sorted in non-descending order
      Since:
        6.0.0

    - #### public String join()

      Concatenates the string representation of each item in this array.

      Returns:
        the joined String
      Since:
        5.0.0

    - #### public String join(String separator)

      Concatenates the string representation of each item in this array, with the given String as a separator between each item.

      Parameters:
        `separator` - a String separator
      Returns:
        the joined String
      Since:
        2.4.1

    - #### public int last()

      Returns the last item from the int array.

           int[] ints = [1, 3, 5]
           assert ints.last() == 5

      throws:
        NoSuchElementException if the array is empty
      Returns:
        the last element
      Since:
        5.0.0

    - #### public int max()

      Adds max() method to int arrays.

      Example usage:

           int[] nums = [1, 3, 2]
           assert 3 == nums.max()

      Returns:
        the maximum value
      Since:
        3.0.8

    - #### public int max(IntComparator comparator)

      Selects the maximum value found from the int array using the supplied IntComparator to determine the maximum of any two values.

           int[] nums = [10, 20, -30]
           assert 20 == nums.max{ n, m -> n <=> m }
           assert -30 == nums.max{ n, m -> n.abs() <=> m.abs() }

      throws:
        UnsupportedOperationException if the array is empty
      Parameters:
        `comparator` - a comparator, i.e. returns a negative value if the first parameter is less than the second
      Returns:
        the maximum value
      Since:
        5.0.0

    - #### public int max(IntUnaryOperator operator)

      Selects the maximum value found from the int array using the supplied IntUnaryOperator to determine the maximum of any two values. The operator is applied to each array element and the results are compared.

           int[] nums = [10, 20, -30]
           assert 20 == nums.max{ it }
           assert -30 == nums.max{ it.abs() }

      throws:
        UnsupportedOperationException if the array is empty
      Parameters:
        `operator` - an operator that returns an int used for comparing values
      Returns:
        the maximum value
      Since:
        5.0.0

    - #### public int maxComparing(Comparator<Integer> comparator)

      Selects the maximum value found from the int array using the comparator to determine the maximum of any two values.

           int[] nums = [10, 20, 30]
           assert 30 == nums.maxComparing(Comparator.naturalOrder())
           assert 10 == nums.maxComparing(Comparator.reverseOrder())

      Parameters:
        `comparator` - a Comparator
      Returns:
        the maximum value
      See Also:
        DefaultGroovyMethods#max(Iterator, java.util.Comparator)
      Since:
        5.0.0

    - #### public int min()

      Adds min() method to int arrays.

      Example usage:

           int[] nums = [20, 10, 30]
           assert 10 == nums.min()

      Returns:
        the minimum value
      Since:
        3.0.8

    - #### public int min(IntComparator comparator)

      Selects the minimum value found from the int array using the supplied IntComparator to determine the minimum of any two values.

           int[] nums = [10, -20, 30]
           assert -20 == nums.min{ n, m -> n <=> m }
           assert 10 == nums.min{ n, m -> n.abs() <=> m.abs() }

      throws:
        UnsupportedOperationException if the array is empty
      Parameters:
        `comparator` - a comparator, i.e. returns a negative value if the first parameter is less than the second
      Returns:
        the minimum value
      Since:
        5.0.0

    - #### public int min(IntUnaryOperator operator)

      Selects the minimum value found from the int array using the supplied IntUnaryOperator to determine the minimum of any two values. The operator is applied to each array element and the results are compared.

           int[] nums = [10, -20, 30]
           assert -20 == nums.min{ n -> n }
           assert 10 == nums.min{ n -> n.abs() }

      throws:
        UnsupportedOperationException if the array is empty
      Parameters:
        `operator` - an operator that returns an int used for comparing values
      Returns:
        the minimum value
      Since:
        5.0.0

    - #### public int minComparing(Comparator<Integer> comparator)

      Selects the minimum value found from the int array using the comparator to determine the minimum of any two values.

           int[] nums = [1, 2, 3]
           assert 1 == nums.minComparing(Comparator.naturalOrder())
           assert 3 == nums.minComparing(Comparator.reverseOrder())

      Parameters:
        `comparator` - a Comparator
      Returns:
        the minimum value
      See Also:
        DefaultGroovyMethods#min(Iterator, java.util.Comparator)
      Since:
        5.0.0

    - #### public int partitionPoint(IntRange range, IntPredicate condition)

      Returns the index of the partition point according to the given predicate (the index of the first element of the second partition). The arr is assumed to be partitioned according to the given predicate.

           def arr = [7, 15, 3, 5, 4, 12, 6] as int[]
           assert arr.partitionPoint(0..<arr.size()) { it%2 != 0 } == 4

           def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as int[]
           // usage case like lower_bound(cpp), bisect_left(python)
           assert arr.partitionPoint(0..<arr.size()) { it < 4 } == 4
           // usage case like upper_bound(cpp), bisect_right(python)
           assert arr.partitionPoint(0..<arr.size()) { it <= 4 } == 6
           // for all match condition
           assert arr.partitionPoint(0..<arr.size()) { it <= 100 } == arr.size()
           // for all match condition
           assert arr.partitionPoint(0..<arr.size()) { it <= 0 } == 0
           // for no match condition with range
           assert arr.partitionPoint(2..<arr.size()) { it <= 0 } == 2

      Parameters:
        `range` - the range [l,r] to find data match the condition
        `condition` - the matching condition
      Returns:
        an integer that is the index of the first element of the second partition
      Since:
        5.0.0

    - #### public int partitionPoint(IntPredicate condition)

      Returns the index of the partition point according to the given predicate (the index of the first element of the second partition). The arr is assumed to be partitioned according to the given predicate.

           def arr = [7, 15, 3, 5, 4, 12, 6] as int[]
           assert arr.partitionPoint{ it%2 != 0 } == 4

           def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as int[]
           // usage case like lower_bound(cpp), bisect_left(python)
           assert arr.partitionPoint{ it < 4 } == 4
           // usage case like upper_bound(cpp), bisect_right(python)
           assert arr.partitionPoint{ it <= 4 } == 6
           // for all match condition
           assert arr.partitionPoint{ it <= 100 } == arr.size()
           // for no match condition
           assert arr.partitionPoint{ it <= 0 } == 0
           // empty input
           assert (new int[0]).partitionPoint{ it < 4 } == 0

      Parameters:
        `condition` - the matching condition
      Returns:
        an integer that is the index of the first element of the second partition
      Since:
        5.0.0

    - #### public void putAt(IntRange range, int[] source)

      A helper method to allow arrays to be set with subscript operators.

           int[] from = [1, 1, 1]
           int[] to = [0, 0, 0, 0, 0]
           to[1..3] = from
           assert to == [0, 1, 1, 1, 0]

      throws:
        IndexOutOfBoundsException if the source doesn't have sufficient elements or the IntRange is too big for the self array
      Parameters:
        `range` - the subset of the array to set
        `source` - the source array from which new values will come
      Since:
        5.0.0

    - #### public void putAt(IntRange range, Iterable<Number> source)

      A helper method to allow arrays to be set with subscript operators. Zero will be used if the source iterable has insufficient elements.

           def from = [1, 1, 1]
           int[] to = [0, 0, 0, 0, 0]
           to[1..3] = from
           assert to == [0, 1, 1, 1, 0]

      Parameters:
        `range` - the subset of the array to set
        `source` - the source array from which new values will come
      Since:
        5.0.0

    - #### public int[] reverse()

      Creates a new int array containing items which are the same as this array but in reverse order.

           int[] array = 1..2
           assert array.reverse() == 2..1

      Returns:
        an array containing the reversed items
      See Also:
        reverse(int[], boolean)
      Since:
        5.0.0

    - #### public int[] reverse(boolean mutate)

      Reverses the items in an array. If mutate is true, the original array is modified in place and returned. Otherwise, a new array containing the reversed items is produced.

           int[] array = 1..3
           def yarra = array.reverse(true)
           assert array == 3..1
           assert yarra == 3..1
           assert array === yarra
           yarra = array.reverse(false)
           assert array !== yarra
           assert array == 3..1
           assert yarra == 1..3

      Parameters:
        `mutate` - `true` if the array itself should be reversed in place, `false` if a new array should be created
      Returns:
        an array containing the reversed items
      Since:
        5.0.0

    - #### public int[] reverseEach(Closure<?> closure)

      Iterates through an int[] in reverse order passing each int to the given closure.

           int[] array = [0, 1, 2]
           String result = ''
           array.reverseEach{ result += it }
           assert result == '210'

      Parameters:
        `closure` - the closure applied on each int
      Returns:
        the self array
      Since:
        5.0.0

    - #### public int size()

      Provides arrays with a `size` method similar to collections.

      Returns:
        the length of the array
      Since:
        1.0

    - #### public Stream<Integer> stream()

      Returns a sequential Stream with the specified array as its source.

      Returns:
        a `Stream` for the array
      Since:
        2.5.0

    - #### public int sum()

      Sums the items in an array.

          assert 1+2+3+4 == ([1,2,3,4] as int[]).sum()

      Returns:
        The sum of all the items
      Since:
        2.4.2

    - #### public int sum(IntUnaryOperator operator)

      Calculates the sum of values found from applying the operator to members of the int array.

           int[] nums = [10, -20, 30]
           assert 20 == nums.sum{ n -> n }
           assert 60 == nums.sum{ n -> n.abs() }
           int[] squares = [1, 4, 9]
           assert squares.sum(java.util.function.IntUnaryOperator.identity()) == 14
           assert squares.sum(Math::sqrt) == 6

      throws:
        UnsupportedOperationException if the array is empty
      Parameters:
        `operator` - an operator that returns an int used for summing values
      Returns:
        the sum value of all values after applying the operator
      Since:
        5.0.0

    - #### public int sum(int initialValue)

      Sums the items in an array, adding the result to some initial value.

          assert 5+1+2+3+4 == ([1,2,3,4] as int[]).sum(5)

      Parameters:
        `initialValue` - the items in the array will be summed to this initial value
      Returns:
        The sum of all the items.
      Since:
        2.4.2

    - #### public int[] swap(int i, int j)

      Swaps two elements at the specified positions.

      Example:

           assert ([1, 3, 2, 4] as int[]) == ([1, 2, 3, 4] as int[]).swap(1, 2)

      Parameters:
        `i` - a position
        `j` - a position
      Returns:
        self
      Since:
        2.4.0

    - #### public int[] tail()

      Returns the items from the int array excluding the first item.

           int[] ints = [1, 3, 5]
           def result = ints.tail()
           assert result == [3, 5]
           assert ints.class.componentType == result.class.componentType

      throws:
        UnsupportedOperationException if the array is empty
      Returns:
        an array without its first element
      Since:
        5.0.0

    - #### public List<Integer> toImmutableList()

      Converts this array to an immutable List of the same size, with each element added to the list.

      Returns:
        An immutable list containing the contents of this array.
      Since:
        6.0.0

    - #### public Set<Integer> toImmutableSet()

      Converts this array to an immutable Set, with each unique element added to the set.

           int[] array = [1, 2, 3, 2, 1]
           Set expected = [1, 2, 3]
           assert array.toImmutableSet() == expected

      Returns:
        An immutable set containing the unique contents of this array.
      Since:
        6.0.0

    - #### public List<Integer> toList()

      Converts this array to a List of the same size, with each element added to the list.

      Returns:
        A list containing the contents of this array.
      Since:
        1.0

    - #### public Set<Integer> toSet()

      Converts this array to a Set, with each unique element added to the set.

           int[] array = [1, 2, 3, 2, 1]
           Set expected = [1, 2, 3]
           assert array.toSet() == expected

      Returns:
        A set containing the unique contents of this array.
      Since:
        1.8.0

    - #### public String toString()

      Returns the string representation of the given array.

           int[] array = [1, 2, 3, 2, 1]
           assert array.toString() == '[1, 2, 3, 2, 1]'

      Returns:
        the string representation
      Since:
        1.6.0

    - #### public List<Tuple2<Integer, Integer>> withIndex()

      Zips an int array with indices in (value, index) order.

      Example usage:

           int[] nums = [42, -1]
           assert [[42, 0], [-1, 1]] == nums.withIndex()
           assert ["0: 42", "1: -1"] == nums.withIndex().collect { n, idx -> "$idx: $n" }

      Returns:
        a zipped list with indices
      See Also:
        DefaultGroovyMethods#withIndex(Iterable)#withIndex(Iterable)
      Since:
        5.0.0

    - #### public List<Tuple2<Integer, Integer>> withIndex(int offset)

      Zips an int array with indices in (value, index) order starting from a given index.

      Example usage:

           int[] nums = [42, -1]
           assert [[42, 5], [-1, 6]] == nums.withIndex(5)
           assert ["5: 42", "6: -1"] == nums.withIndex(5).collect { n, idx -> "$idx: $n" }

      Parameters:
        `offset` - an index to start from
      Returns:
        a zipped list with indices
      See Also:
        DefaultGroovyMethods#withIndex(Iterable, int)#withIndex(Iterable, int)
      Since:
        5.0.0

    - #### public List<Tuple2<Integer, Integer>> zip(int[] other)

      A list of all the pairs from two arrays.

           int[] small = [1, 2, 3]
           int[] large = [100, 200, 300]
           assert [101, 202, 303] == small.zip(large).collect{ a, b -> a + b }
           assert [small, large].transpose() == small.zip(large)

      Parameters:
        `other` - another int[]
      Returns:
        a list of all the pairs from self and other
      Since:
        5.0.0

    - #### public Iterator<Tuple2<Integer, Integer>> zipping(int[] other)

      An iterator of all the pairs from two arrays.

           int[] small = [1, 2, 3]
           int[] large = [100, 200, 300]
           assert [101, 202, 303] == small.zipping(large).collect{ a, b -> a + b }
           assert [small, large].transpose() == small.zipping(large).toList()

      Parameters:
        `other` - another int[]
      Returns:
        an iterator of all the pairs from self and other
      Since:
        5.0.0