Package:

## Class double[]

- - ### Methods Summary

    Methods
    Return type | Name and parameters
    --- | ---
    `boolean` | `any(Closure predicate)` Iterates over the contents of a double Array, and checks whether a predicate is valid for at least one element.
    `boolean` | `asBoolean()` Coerces a double array to a boolean value.
    `double` | `average()` Calculates the average of the doubles in the array.
    `List` | `chop(int chopSizes)` Chops the double array into pieces, returning lists with sizes corresponding to the supplied chop sizes.
    `boolean` | `contains(Object value)` Checks whether the array contains the given value.
    `Number` | `count(Object value)` Counts the number of occurrences of the given value inside this array.
    `DoubleStream` | `doubleStream()` Returns a sequential DoubleStream with the specified array as its source.
    `double[]` | `each(DoubleConsumer consumer)` Iterates through a double[] passing each double to the given consumer.
    `double[]` | `eachWithIndex(Closure closure)` Iterates through a double[], passing each double and the element's index (a counter starting at zero) to the given closure.
    `boolean` | `equals(double[] right)` Compares the contents of this array to the contents of the given array.
    `boolean` | `every(Closure predicate)` Iterates over the contents of a double Array, and checks whether a predicate is valid for all elements.
    `double` | `first()` Returns the first item from the double array.
    `List` | `flatten()` Flattens an array.
    `List` | `getAt(IntRange range)` Supports the subscript operator for a double array with an IntRange giving the desired indices.
    `List` | `getAt(ObjectRange range)` Supports the subscript operator for a double array with an ObjectRange giving the desired indices.
    `List` | `getAt(Range range)` Supports the subscript operator for a double array with a range giving the desired indices.
    `List` | `getAt(Collection indices)` Supports the subscript operator for a double array with a (potentially nested) collection giving the desired indices.
    `IntRange` | `getIndices()` Returns indices of the double array.
    `double` | `head()` Returns the first item from the double array.
    `Map` | `indexed()` Zips a double[] with indices in (index, value) order starting from index 0.
    `Map` | `indexed(int offset)` Zips a double[] with indices in (index, value) order.
    `double[]` | `init()` Returns the items from the double array excluding the last item.
    `String` | `join()` Concatenates the string representation of each item in this array.
    `String` | `join(String separator)` Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    `double` | `last()` Returns the last item from the double array.
    `double` | `max()` Adds max() method to double arrays.
    `double` | `max(DoubleComparator comparator)` Selects the maximum value found from the double array using the supplier DoubleComparator to determine the maximum of any two values.
    `double` | `max(DoubleUnaryOperator operator)` Selects the maximum value found from the double array using the supplier DoubleUnaryOperator to determine the maximum of any two values.
    `double` | `maxComparing(Comparator comparator)` Selects the maximum value found from the double array using the comparator to determine the maximum of any two values.
    `double` | `min()` Adds min() method to double arrays.
    `double` | `min(DoubleComparator comparator)` Selects the minimum value found from the double array using the supplier DoubleBinaryOperator as a comparator to determine the minimum of any two values.
    `double` | `min(DoubleUnaryOperator operator)` Selects the minimum value found from the double array using the supplier DoubleUnaryOperator to determine the minimum of any two values.
    `double` | `minComparing(Comparator comparator)` Selects the minimum value found from the double array using the comparator to determine the minimum of any two values.
    `double[]` | `reverse()` Creates a new double array containing items which are the same as this array but in reverse order.
    `double[]` | `reverse(boolean mutate)` Reverses the items in an array.
    `double[]` | `reverseEach(Closure closure)` Iterates through a double[] in reverse order passing each double to the given closure.
    `int` | `size()` Provides arrays with a `size` method similar to collections.
    `Stream` | `stream()` Returns a sequential Stream with the specified array as its source.
    `double` | `sum()` Sums the items in an array.
    `double` | `sum(double initialValue)` Sums the items in an array, adding the result to some initial value.
    `double[]` | `swap(int i, int j)` Swaps two elements at the specified positions.
    `double[]` | `tail()` Returns the items from the double array excluding the first item.
    `List` | `toList()` Converts this array to a List of the same size, with each element added to the list.
    `Set` | `toSet()` Converts this array to a Set, with each unique element added to the set.
    `String` | `toString()` Returns the string representation of the given array.
    `Iterator` | `zip(double[] other)` An iterator of all the pairs of two arrays.

- - ### Methods Detail

    - #### public boolean any(Closure predicate)

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

          double[] array = [0.0d, 1.0d, 2.0d]
          assert array.any{ it > 1.5d }
          assert !array.any{ it > 2.5d }

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

    - #### public boolean asBoolean()

      Coerces a double array to a boolean value. A double array is false if the array is of length 0, and true otherwise.

      Returns:
        the array's boolean value
      Since:
        1.7.4

    - #### public double average()

      Calculates the average of the doubles in the array.

          assert 5.0d == ([2,4,6,8] as double[]).average()

      Returns:
        The average of the items
      Since:
        3.0.0

    - #### public List chop(int chopSizes)

      Chops the double 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.

          double[] 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
      Since:
        5.0.0
      See Also:
        ArrayGroovyMethods#collate(Object[], int) to chop a list into pieces of a fixed size

    - #### 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`).

          double[] array = [10.0d, 20.0d, 20.0d, 30.0d]
          assert array.count(20.0d) == 2

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

    - #### public DoubleStream doubleStream()

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

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

    - #### public double[] each(DoubleConsumer consumer)

      Iterates through a double[] passing each double to the given consumer.

          double[] array = [0d, 1d, 2d]
          String result = ''
          array.each{ result += it }
          assert result == '0.01.02.0'

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

    - #### public double[] eachWithIndex(Closure closure)

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

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

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

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

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

      Example usage:

          double[] array1 = [4.0d, 8.0d]
          double[] array2 = [4.0d, 8.0d]
          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 a double Array, and checks whether a predicate is valid for all elements.

          double[] array = [0.0d, 1.0d, 2.0d]
          assert array.every{ it < 2.5d }
          assert !array.every{ it > 1.5d }

      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 double first()

      Returns the first item from the double array.

          double[] doubles = [10.0d, 20.0d, 30.0d]
          assert doubles.first() == 10.0d

      An alias for `head()`.
      Returns:
        the first element
      Since:
        5.0.0

    - #### public List 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.

          double[] array = [0.0d, 1.0d]
          assert array.flatten() == [0.0d, 1.0d]

      Returns:
        a Collection of the array elements
      Since:
        1.6.0

    - #### public List getAt(IntRange range)

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

          double[] array = [0.0d, 10.0d, 20.0d, 30.0d, 40.0d]
          assert array[2..3] == [20.0d, 30.0d]
          assert array[-2..-1] == [30.0d, 40.0d]
          assert array[-1..-2] == [40.0d, 30.0d]

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

    - #### public List getAt(ObjectRange range)

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

          double[] array = [0.0d, 10.0d, 20.0d, 30.0d, 40.0d]
          def range = new ObjectRange(2, 3)
          assert array[range] == [20.0d, 30.0d]

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

    - #### public List getAt(Range range)

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

          double[] array = [1.0d, 3.0d, 5.0d, 7.0d, 9.0d, 11.0d]
          assert array[2..<2] == [] // EmptyRange
          assert array[(0..5.5).step(2)] == [1.0d, 5.0d, 9.0d]   // NumberRange
          assert array[(1..5.5).step(2)] == [3.0d, 7.0d, 11.0d]  // NumberRange

      Parameters:
        `range` - a range indicating the indices for the items to retrieve
      Returns:
        list of the retrieved doubles
      Since:
        1.0

    - #### public List getAt(Collection indices)

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

          double[] array = [0.0d, 2.0d, 4.0d, 6.0d, 8.0d]
          assert array[2, 3] == [4.0d, 6.0d]
          assert array[1, 0..1, [0, [-1]]] == [2.0d, 0.0d, 2.0d, 0.0d, 8.0d]

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

    - #### public IntRange getIndices()

      Returns indices of the double array.

          double[] array = [0.0d, 1.0d]
          assert array.indices == 0..1

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

    - #### public double head()

      Returns the first item from the double array.

          double[] doubles = [10.0d, 20.0d, 30.0d]
          assert doubles.head() == 10.0d

      An alias for `first()`.
      Returns:
        the first element
      Since:
        5.0.0

    - #### public Map indexed()

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

      Example usage:

          double[] nums = [10.0d, 20.0d, 30.0d]
          assert [0: 10.0d, 1: 20.0d, 2: 30.0d] == nums.indexed()

      Since:
        3.0.8
      See Also:
        double[]#indexed(int)

    - #### public Map indexed(int offset)

      Zips a double[] with indices in (index, value) order.

      Example usage:

          double[] nums = [10.0d, 20.0d, 30.0d]
          assert [5: 10.0d, 6: 20.0d, 7: 30.0d] == nums.indexed(5)

      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
      Since:
        3.0.8
      See Also:
        DefaultGroovyMethods#indexed(Iterable, int)

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

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

          double[] doubles = [10.0d, 20.0d, 30.0d]
          def result = doubles.init()
          assert result == [10.0d, 20.0d]
          assert doubles.class.componentType == result.class.componentType

      Returns:
        an array without its last element
      Since:
        5.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 double last()

      Returns the last item from the double array.

          double[] doubles = [10.0d, 20.0d, 30.0d]
          assert doubles.last() == 30.0d

      Returns:
        the last element
      Since:
        5.0.0

    - #### public double max()

      Adds max() method to double arrays.

      Example usage:

          double[] nums = [1.1d, 3.3d, 2.2d]
          assert 3.3d == nums.max()

      Returns:
        the maximum value
      Since:
        3.0.8

    - #### public double max(DoubleComparator comparator)

      Selects the maximum value found from the double array using the supplier DoubleComparator to determine the maximum of any two values.

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

      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 double max(DoubleUnaryOperator operator)

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

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

      Parameters:
        `operator` - an operator that returns a double used for comparing values
      Returns:
        the maximum value
      Since:
        5.0.0

    - #### public double maxComparing(Comparator comparator)

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

          double[] nums = [10.0d, 20.0d, 30.0d]
          assert 30d == nums.maxComparing(Comparator.naturalOrder())
          assert 10d == nums.maxComparing(Comparator.reverseOrder())

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

    - #### public double min()

      Adds min() method to double arrays.

      Example usage:

          double[] nums = [20.0d, 10.0d, 30.0d]
          assert 10.0d == nums.min()

      Returns:
        the minimum value
      Since:
        3.0.8

    - #### public double min(DoubleComparator comparator)

      Selects the minimum value found from the double array using the supplier DoubleBinaryOperator as a comparator to determine the minimum of any two values.

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

      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 double min(DoubleUnaryOperator operator)

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

          double[] nums = [10d, -20d, 30d]
          assert -20d == nums.min{ it }
          assert 10d == nums.min{ it.abs() }

      Parameters:
        `operator` - an operator that returns a double used for comparing values
      Returns:
        the minimum value
      Since:
        5.0.0

    - #### public double minComparing(Comparator comparator)

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

          double[] nums = [10.0d, 20.0d, 30.0d]
          assert 10d == nums.minComparing(Comparator.naturalOrder())
          assert 30d == nums.minComparing(Comparator.reverseOrder())

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

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

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

          double[] array = [1d, 2d]
          assert array.reverse() == [2d, 1d]

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

    - #### public double[] 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.

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

      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 double[] reverseEach(Closure closure)

      Iterates through a double[] in reverse order passing each double to the given closure.

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

      Parameters:
        `closure` - the closure applied on each double
      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 stream()

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

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

    - #### public double sum()

      Sums the items in an array.

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

      Returns:
        The sum of all the items
      Since:
        2.4.2

    - #### public double sum(double initialValue)

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

          assert (5+1+2+3+4 as double) == ([1,2,3,4] as double[]).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 double[] swap(int i, int j)

      Swaps two elements at the specified positions.

      Example:

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

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

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

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

          double[] doubles = [10.0d, 20.0d, 30.0d]
          def result = doubles.tail()
          assert result == [20.0d, 30.0d]
          assert doubles.class.componentType == result.class.componentType

      Returns:
        an array without its first element
      Since:
        5.0.0

    - #### public List 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 toSet()

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

          double[] array = [1.0d, 2.0d, 3.0d, 2.0d, 1.0d]
          Set expected = [1.0d, 2.0d, 3.0d]
          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.

          double[] array = [1, 2, 3, 2, 1]
          assert array.toString() == '[1.0, 2.0, 3.0, 2.0, 1.0]'

      Returns:
        the string representation
      Since:
        1.6.0

    - #### public Iterator zip(double[] other)

      An iterator of all the pairs of two arrays.

          double[] small = [1.0d, 2.0d, 3.0d]
          double[] large = [100d, 200d, 300d]
          assert [small, large].transpose() == small.zip(large).toList()

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