Package:

## Class boolean[]

- - ### Methods Summary

    Methods
    Return type | Name and parameters
    --- | ---
    `boolean` | `any()` Iterates over the contents of a boolean Array, and checks whether any element is true.
    `boolean` | `any(Closure predicate)` Iterates over the contents of a boolean Array, and checks whether a predicate is valid for at least one element.
    `boolean` | `asBoolean()` Coerces a boolean array to a boolean value.
    `List` | `chop(int chopSizes)` Chops the boolean 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.
    `boolean[]` | `each(Consumer consumer)` Iterates through a boolean[] passing each boolean to the given consumer.
    `boolean[]` | `eachWithIndex(Closure closure)` Iterates through a boolean[], passing each boolean and the element's index (a counter starting at zero) to the given closure.
    `boolean` | `equals(boolean[] right)` Compares the contents of this array to the contents of the given array.
    `boolean` | `every()` Iterates over the contents of a boolean Array, and checks whether every element is true.
    `boolean` | `every(Closure predicate)` Iterates over the contents of a boolean Array, and checks whether a predicate is valid for every element.
    `boolean` | `first()` Returns the first item from the boolean array.
    `List` | `flatten()` Flattens an array.
    `List` | `getAt(IntRange range)` Supports the subscript operator for a boolean array with an IntRange giving the desired indices.
    `List` | `getAt(ObjectRange range)` Supports the subscript operator for a boolean array with an ObjectRange giving the desired indices.
    `List` | `getAt(Range range)` Supports the subscript operator for a boolean array with a range giving the desired indices.
    `List` | `getAt(Collection indices)` Supports the subscript operator for a boolean array with a (potentially nested) collection giving the desired indices.
    `IntRange` | `getIndices()` Returns indices of the boolean array.
    `boolean` | `head()` Returns the first item from the boolean array.
    `boolean[]` | `init()` Returns the items from the boolean 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.
    `boolean` | `last()` Returns the last item from the boolean array.
    `void` | `putAt(IntRange range, boolean[] source)` A helper method to allow arrays to be set with subscript operators.
    `void` | `putAt(IntRange range, Iterable source)` A helper method to allow arrays to be set with subscript operators.
    `boolean[]` | `reverse()` Creates a new boolean array containing items which are the same as this array but in reverse order.
    `boolean[]` | `reverse(boolean mutate)` Reverses the items in an array.
    `boolean[]` | `reverseEach(Closure closure)` Iterates through a boolean[] in reverse order passing each boolean 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.
    `boolean[]` | `swap(int i, int j)` Swaps two elements at the specified positions.
    `boolean[]` | `tail()` Returns the items from the boolean 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.

- - ### Methods Detail

    - #### public boolean any()

      Iterates over the contents of a boolean Array, and checks whether any element is true.

          boolean[] array1 = [false, true]
          assert array1.any()
          boolean[] array2 = [false]
          assert !array2.any()

      Returns:
        true if any boolean is true
      Since:
        5.0.0

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

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

          boolean[] array = [true]
          assert array.any{ it }
          assert !array.any{ !it }

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

    - #### public boolean asBoolean()

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

      Returns:
        the array's boolean value
      Since:
        1.7.4

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

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

          boolean[] array = [false, true, false]
          assert array.chop(1, 2) == [[false], [true, false]]

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

          boolean[] array = [false, true, true]
          assert array.count(true) == 2

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

    - #### public boolean[] each(Consumer consumer)

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

          boolean[] array = [false, true, false]
          String result = ''
          array.each{ result += it.toString()[0] }
          assert result == 'ftf'

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

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

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

          boolean[] array = [false, true, false]
          String result = ''
          array.eachWithIndex{ item, index -> result += "$index($item)" }
          assert result == '0(false)1(true)2(false)'

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

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

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

      Example usage:

          boolean[] array1 = [true, false]
          boolean[] array2 = [true, false]
          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()

      Iterates over the contents of a boolean Array, and checks whether every element is true.

          boolean[] array1 = [false, true]
          assert !array1.every()
          boolean[] array2 = [true, true]
          assert array2.every()

      Returns:
        true if no boolean is false
      Since:
        5.0.0

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

      Iterates over the contents of a boolean Array, and checks whether a predicate is valid for every element.

          boolean[] array = [true]
          assert array.every{ it }
          assert !array.every{ !it }

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

      Returns the first item from the boolean array.

          boolean[] array = [true, false]
          assert array.first() == true

      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.

          boolean[] array = [false, true]
          assert array.flatten() == [false, true]

      Returns:
        a Collection of the array elements
      Since:
        1.6.0

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

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

          boolean[] array = [false, false, true, true, false]
          assert array[2..3] == [true, true]
          assert array[-2..-1] == [true, false]
          assert array[-1..-2] == [false, true]

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

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

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

          boolean[] array = [false, false, true, true, false]
          def range = new ObjectRange(2, 3)
          assert array[range] == [true, true]

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

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

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

          boolean[] array = [false, true, false, true, false, true]
          assert array[2..<2] == [] // EmptyRange
          assert array[(0..5.5).step(2)] == [false, false, false] // NumberRange
          assert array[(1..5.5).step(2)] == [true, true, true]    // NumberRange

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

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

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

          boolean[] array = [false, false, true, true, false]
          assert array[2, 3] == [true, true]
          assert array[0, 0..1, [1, [-1]]] == [false, false, false, false, false]

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

    - #### public IntRange getIndices()

      Returns indices of the boolean array.

          boolean[] array = [false, true]
          assert array.indices == 0..1

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

    - #### public boolean head()

      Returns the first item from the boolean array.

          boolean[] array = [true, false]
          assert array.head() == true

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

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

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

          boolean[] array = [true, false, true]
          def result = array.init()
          assert result == [true, false]
          assert array.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 boolean last()

      Returns the last item from the boolean array.

          boolean[] array = [true, false, true]
          assert array.last() == true

      Returns:
        the last element
      Since:
        5.0.0

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

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

          boolean[] from = [true, true, true]
          boolean[] to = [false, false, false, false, false]
          to[1..3] = from
          assert to == [false, true, true, true, false]

      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 source)

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

          def from = [true, true, true]
          boolean[] to = [false, false, false, false, false]
          to[1..3] = from
          assert to == [false, true, true, true, false]

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

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

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

          boolean[] array = [false, true]
          assert array.reverse() == [true, false]

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

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

          boolean[] array = [false, true, true]
          def yarra = array.reverse(true)
          assert array == [true, true, false]
          assert yarra == [true, true, false]
          assert array === yarra
          yarra = array.reverse(false)
          assert array !== yarra
          assert array == [true, true, false]
          assert yarra == [false, true, true]

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

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

          boolean[] array = [false, true, true]
          String result = ''
          array.reverseEach{ result += it }
          assert result == 'truetruefalse'

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

    - #### public int size()

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

          boolean[] array = [true, false, true]
          assert array.size() == 3

      Returns:
        the length of the array
      Since:
        1.5.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 boolean[] swap(int i, int j)

      Swaps two elements at the specified positions.

      Example:

          assert ([false, true, false, true] as boolean[]) == ([false, false, true, true] as boolean[]).swap(1, 2)

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

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

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

          boolean[] array = [true, false, true]
          def result = array.tail()
          assert result == [false, true]
          assert array.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.6.0

    - #### public Set toSet()

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

          boolean[] array = [true, false, true]
          Set expected = [true, false]
          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.

          boolean[] array = [false, true, false]
          assert array.toString() == '[false, true, false]'

      Returns:
        the string representation
      Since:
        1.6.0