Class ArrayGroovyMethods
public static int[] each(int[] self, Closure closure)
provides a each({i -> })
method for int[]
.
NOTE: While this class contains many 'public' static methods, it is primarily regarded as an internal class (its internal package name suggests this also). We value backwards compatibility of these methods when used within Groovy but value less backwards compatibility at the Java method call level. I.e. future versions of Groovy may remove or move a method call in this file but would normally aim to keep the method available from within Groovy.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
any
(boolean[] self) Iterates over the contents of a boolean Array, and checks whether any element is true.static boolean
Iterates over the contents of a boolean Array, and checks whether a predicate is valid for at least one element.static boolean
Iterates over the contents of a byte Array, and checks whether a predicate is valid for at least one element.static boolean
Iterates over the contents of a char Array, and checks whether a predicate is valid for at least one element.static boolean
Iterates over the contents of a double Array, and checks whether a predicate is valid for at least one element.static boolean
Iterates over the contents of a float Array, and checks whether a predicate is valid for at least one element.static boolean
Iterates over the contents of an int Array, and checks whether a predicate is valid for at least one element.static boolean
Iterates over the contents of a long Array, and checks whether a predicate is valid for at least one element.static boolean
Iterates over the contents of a short Array, and checks whether a predicate is valid for at least one element.static boolean
asBoolean
(boolean[] array) Coerces a boolean array to a boolean value.static boolean
asBoolean
(byte[] array) Coerces a byte array to a boolean value.static boolean
asBoolean
(char[] array) Coerces a char array to a boolean value.static boolean
asBoolean
(double[] array) Coerces a double array to a boolean value.static boolean
asBoolean
(float[] array) Coerces a float array to a boolean value.static boolean
asBoolean
(int[] array) Coerces an int array to a boolean value.static boolean
asBoolean
(long[] array) Coerces a long array to a boolean value.static boolean
asBoolean
(short[] array) Coerces a short array to a boolean value.static BigDecimal
average
(byte[] self) Calculates the average of the bytes in the array.static double
average
(double[] self) Calculates the average of the doubles in the array.static double
average
(float[] self) Calculates the average of the floats in the array.static BigDecimal
average
(int[] self) Calculates the average of the ints in the array.static BigDecimal
average
(long[] self) Calculates the average of the longs in the array.static BigDecimal
average
(short[] self) Calculates the average of the shorts in the array.chop
(boolean[] self, int... chopSizes) Chops the boolean array into pieces, returning lists with sizes corresponding to the supplied chop sizes.chop
(byte[] self, int... chopSizes) Chops the byte array into pieces, returning lists with sizes corresponding to the supplied chop sizes.chop
(char[] self, int... chopSizes) Chops the char array into pieces, returning lists with sizes corresponding to the supplied chop sizes.chop
(double[] self, int... chopSizes) Chops the double array into pieces, returning lists with sizes corresponding to the supplied chop sizes.chop
(float[] self, int... chopSizes) Chops the float array into pieces, returning lists with sizes corresponding to the supplied chop sizes.chop
(int[] self, int... chopSizes) Chops the int array into pieces, returning lists with sizes corresponding to the supplied chop sizes.chop
(long[] self, int... chopSizes) Chops the long array into pieces, returning lists with sizes corresponding to the supplied chop sizes.chop
(short[] self, int... chopSizes) Chops the short array into pieces, returning lists with sizes corresponding to the supplied chop sizes.static boolean
Checks whether the array contains the given value.static boolean
Checks whether the array contains the given value.static boolean
Checks whether the array contains the given value.static boolean
Checks whether the array contains the given value.static boolean
Checks whether the array contains the given value.static boolean
Checks whether the array contains the given value.static boolean
Checks whether the array contains the given value.static boolean
Checks whether the array contains the given value.static Number
Counts the number of occurrences of the given value inside this array.static Number
Counts the number of occurrences of the given value inside this array.static Number
Counts the number of occurrences of the given value inside this array.static Number
Counts the number of occurrences of the given value inside this array.static Number
Counts the number of occurrences of the given value inside this array.static Number
Counts the number of occurrences of the given value inside this array.static Number
Counts the number of occurrences of the given value inside this array.static Number
Counts the number of occurrences of the given value inside this array.static boolean[]
Iterates through a boolean[] passing each boolean to the given closure.static byte[]
Iterates through a byte[] passing each byte to the given closure.static char[]
Iterates through a char[] passing each char to the given closure.static double[]
Iterates through a double[] passing each double to the given closure.static float[]
Iterates through a float[] passing each float to the given closure.static int[]
Iterates through an int[] passing each int to the given closure.static long[]
Iterates through a long[] passing each long to the given closure.static short[]
Iterates through a short[] passing each short to the given closure.static void
Traverse through each byte of this byte array.static boolean[]
eachWithIndex
(boolean[] self, Closure<?> closure) Iterates through a boolean[], passing each boolean and the element's index (a counter starting at zero) to the given closure.static byte[]
eachWithIndex
(byte[] self, Closure<?> closure) Iterates through a byte[], passing each byte and the element's index (a counter starting at zero) to the given closure.static char[]
eachWithIndex
(char[] self, Closure<?> closure) Iterates through a char[], passing each char and the element's index (a counter starting at zero) to the given closure.static double[]
eachWithIndex
(double[] self, Closure<?> closure) Iterates through a double[], passing each double and the element's index (a counter starting at zero) to the given closure.static float[]
eachWithIndex
(float[] self, Closure<?> closure) Iterates through a float[], passing each float and the element's index (a counter starting at zero) to the given closure.static int[]
eachWithIndex
(int[] self, Closure<?> closure) Iterates through an int[], passing each int and the element's index (a counter starting at zero) to the given closure.static long[]
eachWithIndex
(long[] self, Closure<?> closure) Iterates through a long[], passing each long and the element's index (a counter starting at zero) to the given closure.static short[]
eachWithIndex
(short[] self, Closure<?> closure) Iterates through a short[], passing each short and the element's index (a counter starting at zero) to the given closure.static boolean
equals
(boolean[] left, boolean[] right) Compare the contents of this array to the contents of the given array.static boolean
equals
(byte[] left, byte[] right) Compare the contents of this array to the contents of the given array.static boolean
equals
(char[] left, char[] right) Compare the contents of this array to the contents of the given array.static boolean
equals
(double[] left, double[] right) Compare the contents of this array to the contents of the given array.static boolean
equals
(float[] left, float[] right) Compare the contents of this array to the contents of the given array.static boolean
equals
(int[] left, int[] right) Compare the contents of this array to the contents of the given array.static boolean
equals
(long[] left, long[] right) Compare the contents of this array to the contents of the given array.static boolean
equals
(short[] left, short[] right) Compare the contents of this array to the contents of the given array.static boolean
first
(boolean[] self) Returns the first item from the boolean array.static byte
first
(byte[] self) Returns the first item from the byte array.static char
first
(char[] self) Returns the first item from the char array.static double
first
(double[] self) Returns the first item from the double array.static float
first
(float[] self) Returns the first item from the float array.static int
first
(int[] self) Returns the first item from the int array.static long
first
(long[] self) Returns the first item from the long array.static short
first
(short[] self) Returns the first item from the short array.static Collection<Boolean>
flatten
(boolean[] self) Flatten an array.static Collection<Boolean>
flatten
(boolean[][] self) Flatten a 2D array into a new collection.static Collection<Byte>
flatten
(byte[] self) Flatten an array.static Collection<Byte>
flatten
(byte[][] self) Flatten a 2D array into a new collection.static Collection<Character>
flatten
(char[] self) Flatten an array.static Collection<Character>
flatten
(char[][] self) Flatten a 2D array into a new collection.static Collection<Double>
flatten
(double[] self) Flatten an array.static Collection<Double>
flatten
(double[][] self) Flatten a 2D array into a new collection.static Collection<Float>
flatten
(float[] self) Flatten an array.static Collection<Float>
flatten
(float[][] self) Flatten a 2D array into a new collection.static Collection<Integer>
flatten
(int[] self) Flatten an array.static Collection<Integer>
flatten
(int[][] self) Flatten a 2D array into a new collection.static Collection<Long>
flatten
(long[] self) Flatten an array.static Collection<Long>
flatten
(long[][] self) Flatten a 2D array into a new collection.static Collection<Short>
flatten
(short[] self) Flatten an array.static Collection<Short>
flatten
(short[][] self) Flatten a 2D array into a new collection.Support the subscript operator for a boolean array with an IntRange giving the desired indices.getAt
(boolean[] array, ObjectRange range) Support the subscript operator for a boolean array with an ObjectRange giving the desired indices.Support the subscript operator for a boolean array with a range giving the desired indices.getAt
(boolean[] array, Collection indices) Support the subscript operator for a boolean array with a (potentially nested) collection giving the desired indices.Support the subscript operator for a byte array with an IntRange giving the desired indices.getAt
(byte[] array, ObjectRange range) Support the subscript operator for a byte array with an ObjectRange giving the desired indices.Support the subscript operator for a byte array with a range giving the desired indices.getAt
(byte[] array, Collection indices) Support the subscript operator for a byte array with a (potentially nested) collection giving the desired indices.Support the subscript operator for a char array with an IntRange giving the desired indices.getAt
(char[] array, ObjectRange range) Support the subscript operator for a boolean array with an ObjectRange giving the desired indices.Support the subscript operator for a char array with a range giving the desired indices.getAt
(char[] array, Collection indices) Support the subscript operator for a char array with a (potentially nested) collection giving the desired indices.Support the subscript operator for a double array with an IntRange giving the desired indices.getAt
(double[] array, ObjectRange range) Support the subscript operator for a double array with an ObjectRange giving the desired indices.Support the subscript operator for a double array with a range giving the desired indices.getAt
(double[] array, Collection indices) Support the subscript operator for a double array with a (potentially nested) collection giving the desired indices.Support the subscript operator for a float array with an IntRange giving the desired indices.getAt
(float[] array, ObjectRange range) Support the subscript operator for a float array with an ObjectRange giving the desired indices.Support the subscript operator for a float array with a range giving the desired indices.getAt
(float[] array, Collection indices) Support the subscript operator for a float array with a (potentially nested) collection giving the desired indices.Support the subscript operator for an int array with an IntRange giving the desired indices.getAt
(int[] array, ObjectRange range) Support the subscript operator for an int array with an ObjectRange giving the desired indices.Support the subscript operator for an int array with a range giving the desired indices.getAt
(int[] array, Collection indices) Support the subscript operator for an int array with a (potentially nested) collection giving the desired indices.Support the subscript operator for a long array with an IntRange giving the desired indices.getAt
(long[] array, ObjectRange range) Support the subscript operator for a long array with an ObjectRange giving the desired indices.Support the subscript operator for a long array with a range giving the desired indices.getAt
(long[] array, Collection indices) Support the subscript operator for a long array with a (potentially nested) collection giving the desired indices.Support the subscript operator for a short array with an IntRange giving the desired indices.getAt
(short[] array, ObjectRange range) Support the subscript operator for a short array with an ObjectRange giving the desired indices.Support the subscript operator for a short array with a range giving the desired indices.getAt
(short[] array, Collection indices) Support the subscript operator for a short array with a (potentially nested) collection giving the desired indices.static IntRange
getIndices
(boolean[] self) Returns indices of the boolean array.static IntRange
getIndices
(byte[] self) Returns indices of the byte array.static IntRange
getIndices
(char[] self) Returns indices of the char array.static IntRange
getIndices
(double[] self) Returns indices of the double array.static IntRange
getIndices
(float[] self) Returns indices of the float array.static IntRange
getIndices
(int[] self) Returns indices of the int array.static IntRange
getIndices
(long[] self) Returns indices of the long array.static IntRange
getIndices
(short[] self) Returns indices of the short array.static boolean
head
(boolean[] self) Returns the first item from the boolean array.static byte
head
(byte[] self) Returns the first item from the byte array.static char
head
(char[] self) Returns the first item from the char array.static double
head
(double[] self) Returns the first item from the double array.static float
head
(float[] self) Returns the first item from the float array.static int
head
(int[] self) Returns the first item from the int array.static long
head
(long[] self) Returns the first item from the long array.static short
head
(short[] self) Returns the first item from the short array.indexed
(double[] self) Zips a double[] with indices in (index, value) order starting from index 0.indexed
(double[] self, int offset) Zips a double[] with indices in (index, value) order.indexed
(int[] self) Zips an int[] with indices in (index, value) order starting from index 0.indexed
(int[] self, int offset) Zips an int[] with indices in (index, value) order.indexed
(long[] self) Zips a long[] with indices in (index, value) order starting from index 0.indexed
(long[] self, int offset) Zips a long[] with indices in (index, value) order.static boolean[]
init
(boolean[] self) Returns the items from the boolean array excluding the last item.static byte[]
init
(byte[] self) Returns the items from the byte array excluding the last item.static char[]
init
(char[] self) Returns the items from the char array excluding the last item.static double[]
init
(double[] self) Returns the items from the double array excluding the last item.static float[]
init
(float[] self) Returns the items from the float array excluding the last item.static int[]
init
(int[] self) Returns the items from the int array excluding the last item.static long[]
init
(long[] self) Returns the items from the long array excluding the last item.static short[]
init
(short[] self) Returns the items from the short array excluding the last item.static String
Concatenates the string representation of each item in this array, with the given String as a separator between each item.static String
Concatenates the string representation of each item in this array, with the given String as a separator between each item.static String
Concatenates the string representation of each item in this array, with the given String as a separator between each item.static String
Concatenates the string representation of each item in this array, with the given String as a separator between each item.static String
Concatenates the string representation of each item in this array, with the given String as a separator between each item.static String
Concatenates the string representation of each item in this array, with the given String as a separator between each item.static String
Concatenates the string representation of each item in this array, with the given String as a separator between each item.static String
Concatenates the string representation of each item in this array, with the given String as a separator between each item.static boolean
last
(boolean[] self) Returns the last item from the boolean array.static byte
last
(byte[] self) Returns the last item from the byte array.static char
last
(char[] self) Returns the last item from the char array.static double
last
(double[] self) Returns the last item from the double array.static float
last
(float[] self) Returns the last item from the float array.static int
last
(int[] self) Returns the last item from the int array.static long
last
(long[] self) Returns the last item from the long array.static short
last
(short[] self) Returns the last item from the short array.static double
max
(double[] self) Adds max() method to double arrays.static double
max
(double[] self, DoubleComparator comparator) Selects the maximum value found from the double array using the supplier DoubleComparator to determine the maximum of any two values.static double
max
(double[] self, DoubleUnaryOperator operator) Selects the maximum value found from the double array using the supplier DoubleUnaryOperator to determine the maximum of any two values.static int
max
(int[] self) Adds max() method to int arrays.static int
max
(int[] self, IntComparator comparator) Selects the maximum value found from the int array using the supplier IntBinaryOperator as a comparator to determine the maximum of any two values.static int
max
(int[] self, IntUnaryOperator operator) Selects the maximum value found from the int array using the supplier IntUnaryOperator to determine the maximum of any two values.static long
max
(long[] self) Adds max() method to long arrays.static long
max
(long[] self, LongComparator comparator) Selects the maximum value found from the long array using the supplier LongBinaryOperator as a comparator to determine the maximum of any two values.static long
max
(long[] self, LongUnaryOperator operator) Selects the maximum value found from the long array using the supplier LongUnaryOperator to determine the maximum of any two values.static double
Selects the maximum value found from the double array using the closure to determine the maximum of any two values.static int
Selects the maximum value found from the int array using the closure to determine the maximum of any two values.static long
Selects the maximum value found from the long array using the closure to determine the maximum of any two values.static double
maxComparing
(double[] self, Comparator<Double> comparator) Selects the maximum value found from the double array using the comparator to determine the maximum of any two values.static int
maxComparing
(int[] self, Comparator<Integer> comparator) Selects the maximum value found from the int array using the comparator to determine the maximum of any two values.static long
maxComparing
(long[] self, Comparator<Long> comparator) Selects the maximum value found from the long array using the comparator to determine the maximum of any two values.static double
min
(double[] self) Adds min() method to double arrays.static double
min
(double[] self, 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.static double
min
(double[] self, DoubleUnaryOperator operator) Selects the minimum value found from the double array using the supplier DoubleUnaryOperator to determine the minimum of any two values.static int
min
(int[] self) Adds min() method to int arrays.static int
min
(int[] self, IntComparator comparator) Selects the minimum value found from the int array using the supplier IntComparator to determine the minimum of any two values.static int
min
(int[] self, IntUnaryOperator operator) Selects the minimum value found from the int array using the supplier IntUnaryOperator to determine the minimum of any two values.static long
min
(long[] self) Adds min() method to long arrays.static long
min
(long[] self, LongComparator comparator) Selects the minimum value found from the long array using the supplier LongBinaryOperator as a comparator to determine the minimum of any two values.static long
min
(long[] self, LongUnaryOperator operator) Selects the minimum value found from the long array using the supplier LongUnaryOperator to determine the minimum of any two values.static double
Selects the minimum value found from the double array using the closure to determine the minimum of any two values.static int
Selects the minimum value found from the int array using the closure to determine the minimum of any two values.static long
Selects the minimum value found from the long array using the closure to determine the minimum of any two values.static double
minComparing
(double[] self, Comparator<Double> comparator) Selects the minimum value found from the double array using the comparator to determine the minimum of any two values.static int
minComparing
(int[] self, Comparator<Integer> comparator) Selects the minimum value found from the int array using the comparator to determine the minimum of any two values.static long
minComparing
(long[] self, Comparator<Long> comparator) Selects the minimum value found from the long array using the comparator to determine the minimum of any two values.static boolean[]
reverse
(boolean[] self) Creates a new boolean array containing items which are the same as this array but in reverse order.static boolean[]
reverse
(boolean[] self, boolean mutate) Reverse the items in an array.static byte[]
reverse
(byte[] self) Creates a new byte array containing items which are the same as this array but in reverse order.static byte[]
reverse
(byte[] self, boolean mutate) Reverse the items in an array.static char[]
reverse
(char[] self) Creates a new char array containing items which are the same as this array but in reverse order.static char[]
reverse
(char[] self, boolean mutate) Reverse the items in an array.static double[]
reverse
(double[] self) Creates a new double array containing items which are the same as this array but in reverse order.static double[]
reverse
(double[] self, boolean mutate) Reverse the items in an array.static float[]
reverse
(float[] self) Creates a new float array containing items which are the same as this array but in reverse order.static float[]
reverse
(float[] self, boolean mutate) Reverse the items in an array.static int[]
reverse
(int[] self) Creates a new int array containing items which are the same as this array but in reverse order.static int[]
reverse
(int[] self, boolean mutate) Reverse the items in an array.static long[]
reverse
(long[] self) Creates a new long array containing items which are the same as this array but in reverse order.static long[]
reverse
(long[] self, boolean mutate) Reverse the items in an array.static short[]
reverse
(short[] self) Creates a new short array containing items which are the same as this array but in reverse order.static short[]
reverse
(short[] self, boolean mutate) Reverse the items in an array.static boolean[]
reverseEach
(boolean[] self, Closure<?> closure) Iterates through a boolean[] in reverse order passing each boolean to the given closure.static byte[]
reverseEach
(byte[] self, Closure<?> closure) Iterates through a byte[] in reverse order passing each byte to the given closure.static char[]
reverseEach
(char[] self, Closure<?> closure) Iterates through a char[] in reverse order passing each char to the given closure.static double[]
reverseEach
(double[] self, Closure<?> closure) Iterates through a double[] in reverse order passing each double to the given closure.static float[]
reverseEach
(float[] self, Closure<?> closure) Iterates through a float[] in reverse order passing each float to the given closure.static int[]
reverseEach
(int[] self, Closure<?> closure) Iterates through an int[] in reverse order passing each int to the given closure.static long[]
reverseEach
(long[] self, Closure<?> closure) Iterates through a long[] in reverse order passing each long to the given closure.static short[]
reverseEach
(short[] self, Closure<?> closure) Iterates through a short[] in reverse order passing each short to the given closure.static int
size
(boolean[] array) Provide arrays with asize
method similar to collections.static int
size
(byte[] array) Provide arrays with asize
method similar to collections.static int
size
(char[] array) Provide arrays with asize
method similar to collections.static int
size
(double[] array) Provide arrays with asize
method similar to collections.static int
size
(float[] array) Provide arrays with asize
method similar to collections.static int
size
(int[] array) Provide arrays with asize
method similar to collections.static int
size
(long[] array) Provide arrays with asize
method similar to collections.static int
size
(short[] array) Provide arrays with asize
method similar to collections.static byte
sum
(byte[] self) Sums the items in an array.static byte
sum
(byte[] self, byte initialValue) Sums the items in an array, adding the result to some initial value.static char
sum
(char[] self) Sums the items in an array.static char
sum
(char[] self, char initialValue) Sums the items in an array, adding the result to some initial value.static double
sum
(double[] self) Sums the items in an array.static double
sum
(double[] self, double initialValue) Sums the items in an array, adding the result to some initial value.static float
sum
(float[] self) Sums the items in an array.static float
sum
(float[] self, float initialValue) Sums the items in an array, adding the result to some initial value.static int
sum
(int[] self) Sums the items in an array.static int
sum
(int[] self, int initialValue) Sums the items in an array, adding the result to some initial value.static long
sum
(long[] self) Sums the items in an array.static long
sum
(long[] self, long initialValue) Sums the items in an array, adding the result to some initial value.static short
sum
(short[] self) Sums the items in an array.static short
sum
(short[] self, short initialValue) Sums the items in an array, adding the result to some initial value.static boolean[]
swap
(boolean[] self, int i, int j) Swaps two elements at the specified positions.static byte[]
swap
(byte[] self, int i, int j) Swaps two elements at the specified positions.static char[]
swap
(char[] self, int i, int j) Swaps two elements at the specified positions.static double[]
swap
(double[] self, int i, int j) Swaps two elements at the specified positions.static float[]
swap
(float[] self, int i, int j) Swaps two elements at the specified positions.static int[]
swap
(int[] self, int i, int j) Swaps two elements at the specified positions.static long[]
swap
(long[] self, int i, int j) Swaps two elements at the specified positions.static short[]
swap
(short[] self, int i, int j) Swaps two elements at the specified positions.static boolean[]
tail
(boolean[] self) Returns the items from the boolean array excluding the first item.static byte[]
tail
(byte[] self) Returns the items from the byte array excluding the first item.static char[]
tail
(char[] self) Returns the items from the char array excluding the first item.static double[]
tail
(double[] self) Returns the items from the double array excluding the first item.static float[]
tail
(float[] self) Returns the items from the float array excluding the first item.static int[]
tail
(int[] self) Returns the items from the int array excluding the first item.static long[]
tail
(long[] self) Returns the items from the long array excluding the first item.static short[]
tail
(short[] self) Returns the items from the short array excluding the first item.toList
(boolean[] array) Converts this array to a List of the same size, with each element added to the list.toList
(byte[] array) Converts this array to a List of the same size, with each element added to the list.toList
(char[] array) Converts this array to a List of the same size, with each element added to the list.toList
(double[] array) Converts this array to a List of the same size, with each element added to the list.toList
(float[] array) Converts this array to a List of the same size, with each element added to the list.toList
(int[] array) Converts this array to a List of the same size, with each element added to the list.toList
(long[] array) Converts this array to a List of the same size, with each element added to the list.toList
(short[] array) Converts this array to a List of the same size, with each element added to the list.toSet
(boolean[] array) Converts this array to a Set, with each unique element added to the set.toSet
(byte[] array) Converts this array to a Set, with each unique element added to the set.toSet
(char[] array) Converts this array to a Set, with each unique element added to the set.toSet
(double[] array) Converts this array to a Set, with each unique element added to the set.toSet
(float[] array) Converts this array to a Set, with each unique element added to the set.toSet
(int[] array) Converts this array to a Set, with each unique element added to the set.toSet
(long[] array) Converts this array to a Set, with each unique element added to the set.toSet
(short[] array) Converts this array to a Set, with each unique element added to the set.static String
toString
(boolean[] self) Returns the string representation of the given array.static String
toString
(byte[] self) Returns the string representation of the given array.static String
toString
(char[] self) Returns the string representation of the given array.static String
toString
(double[] self) Returns the string representation of the given array.static String
toString
(float[] self) Returns the string representation of the given array.static String
toString
(int[] self) Returns the string representation of the given array.static String
toString
(long[] self) Returns the string representation of the given array.static String
toString
(short[] self) Returns the string representation of the given array.static boolean[][]
transpose
(boolean[][] self) A transpose method for 2D boolean arrays.static byte[][]
transpose
(byte[][] self) A transpose method for 2D byte arrays.static char[][]
transpose
(char[][] self) A transpose method for 2D char arrays.static double[][]
transpose
(double[][] self) A transpose method for 2D double arrays.static float[][]
transpose
(float[][] self) A transpose method for 2D float arrays.static int[][]
transpose
(int[][] self) A transpose method for 2D int arrays.static long[][]
transpose
(long[][] self) A transpose method for 2D long arrays.static short[][]
transpose
(short[][] self) A transpose method for 2D short arrays.Methods inherited from class org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, createSimilarArray, createSimilarCollection, createSimilarCollection, createSimilarCollection, createSimilarList, createSimilarMap, createSimilarOrDefaultCollection, createSimilarQueue, createSimilarSet, normaliseIndex, sameType, subListBorders, subListBorders, subListRange, writeUTF16BomIfRequired, writeUTF16BomIfRequired, writeUTF16BomIfRequired, writeUTF16BomIfRequired
-
Field Details
-
FIRST
- See Also:
-
-
Method Details
-
any
public static boolean any(boolean[] self) 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()
- Parameters:
self
- the boolean array over which we iterate- Returns:
- true if any iteration for the booleans matches the closure predicate
- Since:
- 5.0.0
-
any
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:
self
- the boolean array over which we iteratepredicate
- the closure predicate used for matching- Returns:
- true if any iteration for the booleans matches the closure predicate
- Since:
- 5.0.0
-
any
Iterates over the contents of a byte Array, and checks whether a predicate is valid for at least one element.byte[] array = [0, 1, 2] assert array.any{ it > 1 } assert !array.any{ it > 3 }
- Parameters:
self
- the byte array over which we iteratepredicate
- the closure predicate used for matching- Returns:
- true if any iteration for the bytes matches the closure predicate
- Since:
- 5.0.0
-
any
Iterates over the contents of a char Array, and checks whether a predicate is valid for at least one element.char[] array = ['a', 'b', 'c'] assert array.any{ it <= 'a' } assert !array.any{ it < 'a' }
- Parameters:
self
- the char array over which we iteratepredicate
- the closure predicate used for matching- Returns:
- true if any iteration for the chars matches the closure predicate
- Since:
- 5.0.0
-
any
Iterates over the contents of a short Array, and checks whether a predicate is valid for at least one element.short[] array = [0, 1, 2] assert array.any{ it > 1 } assert !array.any{ it > 3 }
- Parameters:
self
- the char array over which we iteratepredicate
- the closure predicate used for matching- Returns:
- true if any iteration for the shorts matches the closure predicate
- Since:
- 5.0.0
-
any
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:
self
- the int array over which we iteratepredicate
- the closure predicate used for matching- Returns:
- true if any iteration for the ints matches the closure predicate
- Since:
- 5.0.0
-
any
Iterates over the contents of a long Array, and checks whether a predicate is valid for at least one element.long[] array = [0L, 1L, 2L] assert array.any{ it > 1L } assert !array.any{ it > 3L }
- Parameters:
self
- the long array over which we iteratepredicate
- the closure predicate used for matching- Returns:
- true if any iteration for the longs matches the closure predicate
- Since:
- 5.0.0
-
any
Iterates over the contents of a float Array, and checks whether a predicate is valid for at least one element.float[] array = [0.0f, 1.0f, 2.0f] assert array.any{ it > 1.5f } assert !array.any{ it > 2.5f }
- Parameters:
self
- the float array over which we iteratepredicate
- the closure predicate used for matching- Returns:
- true if any iteration for the floats matches the closure predicate
- Since:
- 5.0.0
-
any
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:
self
- the double array over which we iteratepredicate
- the closure predicate used for matching- Returns:
- true if any iteration for the doubles matches the closure predicate
- Since:
- 5.0.0
-
asBoolean
public static boolean asBoolean(boolean[] array) Coerces a boolean array to a boolean value. A boolean array is false if the array is of length 0, and true otherwise.- Parameters:
array
- an array- Returns:
- the array's boolean value
- Since:
- 1.7.4
-
asBoolean
public static boolean asBoolean(byte[] array) Coerces a byte array to a boolean value. A byte array is false if the array is null or of length 0, and true otherwise.byte[] array1 = [] assert !array1 byte[] array2 = [0] assert array2
- Parameters:
array
- an array- Returns:
- the array's boolean value
- Since:
- 1.7.4
-
asBoolean
public static boolean asBoolean(char[] array) Coerces a char array to a boolean value. A char array is false if the array is of length 0, and true otherwise.- Parameters:
array
- an array- Returns:
- the array's boolean value
- Since:
- 1.7.4
-
asBoolean
public static boolean asBoolean(short[] array) Coerces a short array to a boolean value. A short array is false if the array is of length 0, and true otherwise.- Parameters:
array
- an array- Returns:
- the array's boolean value
- Since:
- 1.7.4
-
asBoolean
public static boolean asBoolean(int[] array) Coerces an int array to a boolean value. An int array is false if the array is of length 0, and true otherwise.- Parameters:
array
- an array- Returns:
- the array's boolean value
- Since:
- 1.7.4
-
asBoolean
public static boolean asBoolean(long[] array) Coerces a long array to a boolean value. A long array is false if the array is of length 0, and true otherwise.- Parameters:
array
- an array- Returns:
- the array's boolean value
- Since:
- 1.7.4
-
asBoolean
public static boolean asBoolean(float[] array) Coerces a float array to a boolean value. A float array is false if the array is of length 0, and true otherwise.- Parameters:
array
- an array- Returns:
- the array's boolean value
- Since:
- 1.7.4
-
asBoolean
public static boolean asBoolean(double[] array) Coerces a double array to a boolean value. A double array is false if the array is of length 0, and true otherwise.- Parameters:
array
- an array- Returns:
- the array's boolean value
- Since:
- 1.7.4
-
average
Calculates the average of the bytes in the array.assert 5.0G == ([2,4,6,8] as byte[]).average()
- Parameters:
self
- The array of values to calculate the average of- Returns:
- The average of the items
- Since:
- 3.0.0
-
average
Calculates the average of the shorts in the array.assert 5.0G == ([2,4,6,8] as short[]).average()
- Parameters:
self
- The array of values to calculate the average of- Returns:
- The average of the items
- Since:
- 3.0.0
-
average
Calculates the average of the ints in the array.assert 5.0G == ([2,4,6,8] as int[]).average()
- Parameters:
self
- The array of values to calculate the average of- Returns:
- The average of the items
- Since:
- 3.0.0
-
average
Calculates the average of the longs in the array.assert 5.0G == ([2,4,6,8] as long[]).average()
- Parameters:
self
- The array of values to calculate the average of- Returns:
- The average of the items
- Since:
- 3.0.0
-
average
public static double average(float[] self) Calculates the average of the floats in the array.assert 5.0d == ([2,4,6,8] as float[]).average()
- Parameters:
self
- The array of values to calculate the average of- Returns:
- The average of the items
- Since:
- 3.0.0
-
average
public static double average(double[] self) Calculates the average of the doubles in the array.assert 5.0d == ([2,4,6,8] as double[]).average()
- Parameters:
self
- The array of values to calculate the average of- Returns:
- The average of the items
- Since:
- 3.0.0
-
chop
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:
self
- a boolean Array to be choppedchopSizes
- 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:
-
chop
Chops the byte 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.byte[] array = [0, 1, 2] assert array.chop(1, 2) == [[0], [1, 2]]
- Parameters:
self
- a byte Array to be choppedchopSizes
- 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:
-
chop
Chops the char 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.char[] array = [0, 1, 2] assert array.chop(1, 2) == [[0], [1, 2]]
- Parameters:
self
- a char Array to be choppedchopSizes
- 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:
-
chop
Chops the short 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.short[] array = [0, 1, 2] assert array.chop(1, 2) == [[0], [1, 2]]
- Parameters:
self
- a short Array to be choppedchopSizes
- 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:
-
chop
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:
self
- an int Array to be choppedchopSizes
- 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:
-
chop
Chops the long 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.long[] array = [0, 1, 2] assert array.chop(1, 2) == [[0], [1, 2]]
- Parameters:
self
- a long Array to be choppedchopSizes
- 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:
-
chop
Chops the float 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.float[] array = [0, 1, 2] assert array.chop(1, 2) == [[0], [1, 2]]
- Parameters:
self
- a float Array to be choppedchopSizes
- 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:
-
chop
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:
self
- a double Array to be choppedchopSizes
- 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:
-
contains
Checks whether the array contains the given value.- Parameters:
self
- the array we are searchingvalue
- the value being searched for- Returns:
- true if the array contains the value
- Since:
- 1.8.6
-
contains
Checks whether the array contains the given value.- Parameters:
self
- the array we are searchingvalue
- the value being searched for- Returns:
- true if the array contains the value
- Since:
- 1.8.6
-
contains
Checks whether the array contains the given value.- Parameters:
self
- the array we are searchingvalue
- the value being searched for- Returns:
- true if the array contains the value
- Since:
- 1.8.6
-
contains
Checks whether the array contains the given value.- Parameters:
self
- the array we are searchingvalue
- the value being searched for- Returns:
- true if the array contains the value
- Since:
- 1.8.6
-
contains
Checks whether the array contains the given value.- Parameters:
self
- the array we are searchingvalue
- the value being searched for- Returns:
- true if the array contains the value
- Since:
- 1.8.6
-
contains
Checks whether the array contains the given value.- Parameters:
self
- the array we are searchingvalue
- the value being searched for- Returns:
- true if the array contains the value
- Since:
- 1.8.6
-
contains
Checks whether the array contains the given value.- Parameters:
self
- the array we are searchingvalue
- the value being searched for- Returns:
- true if the array contains the value
- Since:
- 1.8.6
-
contains
Checks whether the array contains the given value.- Parameters:
self
- the array we are searchingvalue
- the value being searched for- Returns:
- true if the array contains the value
- Since:
- 1.8.6
-
count
Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (usingcompareTo(value) == 0
).boolean[] array = [false, true, true] assert array.count(true) == 2
- Parameters:
self
- the array within which we count the number of occurrencesvalue
- the value being searched for- Returns:
- the number of occurrences
- Since:
- 1.6.4
- See Also:
-
count
Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (usingcompareTo(value) == 0
).byte[] array = [10, 20, 20, 30] assert array.count(20) == 2
- Parameters:
self
- the array within which we count the number of occurrencesvalue
- the value being searched for- Returns:
- the number of occurrences
- Since:
- 1.6.4
- See Also:
-
count
Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (usingcompareTo(value) == 0
).char[] array = ['x', 'y', 'z', 'z', 'y'] assert array.count('y') == 2
- Parameters:
self
- the array within which we count the number of occurrencesvalue
- the value being searched for- Returns:
- the number of occurrences
- Since:
- 1.6.4
- See Also:
-
count
Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (usingcompareTo(value) == 0
).short[] array = [10, 20, 20, 30] assert array.count(20) == 2
- Parameters:
self
- the array within which we count the number of occurrencesvalue
- the value being searched for- Returns:
- the number of occurrences
- Since:
- 1.6.4
- See Also:
-
count
Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (usingcompareTo(value) == 0
).int[] array = [10, 20, 20, 30] assert array.count(20) == 2
- Parameters:
self
- the array within which we count the number of occurrencesvalue
- the value being searched for- Returns:
- the number of occurrences
- Since:
- 1.6.4
- See Also:
-
count
Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (usingcompareTo(value) == 0
).long[] array = [10L, 20L, 20L, 30L] assert array.count(20L) == 2
- Parameters:
self
- the array within which we count the number of occurrencesvalue
- the value being searched for- Returns:
- the number of occurrences
- Since:
- 1.6.4
- See Also:
-
count
Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (usingcompareTo(value) == 0
).float[] array = [10.0f, 20.0f, 20.0f, 30.0f] assert array.count(20.0f) == 2
- Parameters:
self
- the array within which we count the number of occurrencesvalue
- the value being searched for- Returns:
- the number of occurrences
- Since:
- 1.6.4
- See Also:
-
count
Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (usingcompareTo(value) == 0
).double[] array = [10.0d, 20.0d, 20.0d, 30.0d] assert array.count(20.0d) == 2
- Parameters:
self
- the array within which we count the number of occurrencesvalue
- the value being searched for- Returns:
- the number of occurrences
- Since:
- 1.6.4
- See Also:
-
each
Iterates through a boolean[] passing each boolean to the given closure.boolean[] array = [false, true, false] String result = '' array.each{ result += it.toString()[0] } assert result == 'ftf'
- Parameters:
self
- the boolean array over which we iterateclosure
- the closure applied on each boolean- Returns:
- the self array
- Since:
- 5.0.0
-
each
Iterates through a byte[] passing each byte to the given closure.byte[] array = [0, 1, 2] String result = '' array.each{ result += it } assert result == '012'
- Parameters:
self
- the byte array over which we iterateclosure
- the closure applied on each byte- Returns:
- the self array
- Since:
- 5.0.0
-
each
Iterates through a char[] passing each char to the given closure.char[] array = ['a' as char, 'b' as char, 'c' as char] String result = '' array.each{ result += it } assert result == 'abc'
- Parameters:
self
- the char array over which we iterateclosure
- the closure applied on each char- Returns:
- the self array
- Since:
- 5.0.0
-
each
Iterates through a short[] passing each short to the given closure.short[] array = [0, 1, 2] String result = '' array.each{ result += it } assert result == '012'
- Parameters:
self
- the short array over which we iterateclosure
- the closure applied on each short- Returns:
- the self array
- Since:
- 5.0.0
-
each
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:
self
- the int array over which we iterateclosure
- the closure applied on each int- Returns:
- the self array
- Since:
- 5.0.0
-
each
Iterates through a long[] passing each long to the given closure.long[] array = [0L, 1L, 2L] String result = '' array.each{ result += it } assert result == '012'
- Parameters:
self
- the long array over which we iterateclosure
- the closure applied on each long- Returns:
- the self array
- Since:
- 5.0.0
-
each
Iterates through a float[] passing each float to the given closure.float[] array = [0f, 1f, 2f] String result = '' array.each{ result += it } assert result == '0.01.02.0'
- Parameters:
self
- the float array over which we iterateclosure
- the closure applied on each float- Returns:
- the self array
- Since:
- 5.0.0
-
each
Iterates through a double[] passing each double to the given closure.double[] array = [0d, 1d, 2d] String result = '' array.each{ result += it } assert result == '0.01.02.0'
- Parameters:
self
- the double array over which we iterateclosure
- the closure applied on each double- Returns:
- the self array
- Since:
- 5.0.0
-
eachByte
Traverse through each byte of this byte array. Alias for each.- Parameters:
self
- a byte arrayclosure
- a closure- Since:
- 1.5.5
- See Also:
-
eachWithIndex
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:
self
- a boolean arrayclosure
- a Closure to operate on each boolean- Returns:
- the self array
- Since:
- 5.0.0
-
eachWithIndex
Iterates through a byte[], passing each byte and the element's index (a counter starting at zero) to the given closure.byte[] array = [10, 20, 30] String result = '' array.eachWithIndex{ item, index
->
result += "$index($item)" } assert result == '0(10)1(20)2(30)'- Parameters:
self
- a byte arrayclosure
- a Closure to operate on each byte- Returns:
- the self array
- Since:
- 5.0.0
-
eachWithIndex
Iterates through a char[], passing each char and the element's index (a counter starting at zero) to the given closure.char[] array = ['a' as char, 'b' as char, 'c' as char] String result = '' array.eachWithIndex{ item, index
->
result += "$index($item)" } assert result == '0(a)1(b)2(c)'- Parameters:
self
- a char arrayclosure
- a Closure to operate on each char- Returns:
- the self array
- Since:
- 5.0.0
-
eachWithIndex
Iterates through a short[], passing each short and the element's index (a counter starting at zero) to the given closure.short[] array = [10, 20, 30] String result = '' array.eachWithIndex{ item, index
->
result += "$index($item)" } assert result == '0(10)1(20)2(30)'- Parameters:
self
- a short arrayclosure
- a Closure to operate on each short- Returns:
- the self array
- Since:
- 5.0.0
-
eachWithIndex
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:
self
- an int arrayclosure
- a Closure to operate on each int- Returns:
- the self array
- Since:
- 5.0.0
-
eachWithIndex
Iterates through a long[], passing each long and the element's index (a counter starting at zero) to the given closure.long[] array = [10L, 20L, 30L] String result = '' array.eachWithIndex{ item, index
->
result += "$index($item)" } assert result == '0(10)1(20)2(30)'- Parameters:
self
- a long arrayclosure
- a Closure to operate on each long- Returns:
- the self array
- Since:
- 5.0.0
-
eachWithIndex
Iterates through a float[], passing each float and the element's index (a counter starting at zero) to the given closure.float[] array = [10f, 20f, 30f] String result = '' array.eachWithIndex{ item, index
->
result += "$index($item)" } assert result == '0(10.0)1(20.0)2(30.0)'- Parameters:
self
- a float arrayclosure
- a Closure to operate on each float- Returns:
- the self array
- Since:
- 5.0.0
-
eachWithIndex
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:
self
- a double arrayclosure
- a Closure to operate on each double- Returns:
- the self array
- Since:
- 5.0.0
-
equals
public static boolean equals(boolean[] left, boolean[] right) Compare 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:
left
- a boolean arrayright
- the array being compared- Returns:
- true if the contents of both arrays are equal.
- Since:
- 5.0.0
-
equals
public static boolean equals(byte[] left, byte[] right) Compare the contents of this array to the contents of the given array.Example usage:
byte[] array1 = [4, 8] byte[] array2 = [4, 8] assert array1 !== array2 assert array1.equals(array2)
- Parameters:
left
- a byte arrayright
- the array being compared- Returns:
- true if the contents of both arrays are equal.
- Since:
- 5.0.0
-
equals
public static boolean equals(char[] left, char[] right) Compare the contents of this array to the contents of the given array.Example usage:
char[] array1 = ['a', 'b'] char[] array2 = ['a', 'b'] assert array1 !== array2 assert array1.equals(array2)
- Parameters:
left
- a char arrayright
- the array being compared- Returns:
- true if the contents of both arrays are equal.
- Since:
- 5.0.0
-
equals
public static boolean equals(short[] left, short[] right) Compare the contents of this array to the contents of the given array.Example usage:
short[] array1 = [4, 8] short[] array2 = [4, 8] assert array1 !== array2 assert array1.equals(array2)
- Parameters:
left
- a short arrayright
- the array being compared- Returns:
- true if the contents of both arrays are equal.
- Since:
- 5.0.0
-
equals
public static boolean equals(int[] left, int[] right) Compare 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:
left
- an int arrayright
- the array being compared- Returns:
- true if the contents of both arrays are equal.
- Since:
- 5.0.0
-
equals
public static boolean equals(long[] left, long[] right) Compare the contents of this array to the contents of the given array.Example usage:
long[] array1 = [4L, 8L] long[] array2 = [4L, 8L] assert array1 !== array2 assert array1.equals(array2)
- Parameters:
left
- a long arrayright
- the array being compared- Returns:
- true if the contents of both arrays are equal.
- Since:
- 5.0.0
-
equals
public static boolean equals(float[] left, float[] right) Compare the contents of this array to the contents of the given array.Example usage:
float[] array1 = [4.0f, 8.0f] float[] array2 = [4.0f, 8.0f] assert array1 !== array2 assert array1.equals(array2)
- Parameters:
left
- a float arrayright
- the array being compared- Returns:
- true if the contents of both arrays are equal.
- Since:
- 5.0.0
-
equals
public static boolean equals(double[] left, double[] right) Compare 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:
left
- a double arrayright
- the array being compared- Returns:
- true if the contents of both arrays are equal.
- Since:
- 5.0.0
-
first
public static boolean first(boolean[] self) Returns the first item from the boolean array.boolean[] array = [true, false] assert array.first() == true
An alias forhead()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
first
public static byte first(byte[] self) Returns the first item from the byte array.byte[] bytes = [1, 2, 3] assert bytes.first() == 1
An alias forhead()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
first
public static char first(char[] self) Returns the first item from the char array.char[] chars = ['a', 'b', 'c'] assert chars.first() == 'a'
An alias forhead()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
first
public static short first(short[] self) Returns the first item from the short array.short[] shorts = [10, 20, 30] assert shorts.first() == 10
An alias forhead()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
first
public static int first(int[] self) Returns the first item from the int array.int[] ints = [1, 3, 5] assert ints.first() == 1
An alias forhead()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
first
public static long first(long[] self) Returns the first item from the long array.long[] longs = [2L, 4L, 6L] assert longs.first() == 2L
An alias forhead()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
first
public static float first(float[] self) Returns the first item from the float array.float[] floats = [2.0f, 4.0f, 6.0f] assert floats.first() == 2.0f
An alias forhead()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
first
public static double first(double[] self) Returns the first item from the double array.double[] doubles = [10.0d, 20.0d, 30.0d] assert doubles.first() == 10.0d
An alias forhead()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
flatten
Flatten an array. This array is added to a new collection. It is an alias fortoList()
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]
- Parameters:
self
- a boolean Array- Returns:
- a Collection of the array elements
- Since:
- 1.6.0
-
flatten
Flatten a 2D array into a new collection. The items are copied row by row.Example usage:
boolean[][] array = [[true, false], [true, false]] assert array.flatten() == [true, false, true, false]
- Parameters:
self
- a 2D boolean Array- Returns:
- a Collection of the array elements
- Since:
- 5.0.0
-
flatten
Flatten an array. This array is added to a new collection. It is an alias fortoList()
but allows algorithms to be written which also work on multidimensional arrays or non-arrays where flattening would be applicable.byte[] array = [0, 1] assert array.flatten() == [0, 1]
- Parameters:
self
- a byte Array- Returns:
- a Collection of the array elements
- Since:
- 1.6.0
-
flatten
Flatten a 2D array into a new collection. The items are copied row by row.Example usage:
byte[][] array = [[0, 1], [2, 3]] assert array.flatten() == [0, 1, 2, 3]
- Parameters:
self
- a 2D byte Array- Returns:
- a Collection of the array elements
- Since:
- 5.0.0
-
flatten
Flatten an array. This array is added to a new collection. It is an alias fortoList()
but allows algorithms to be written which also work on multidimensional arrays or non-arrays where flattening would be applicable.char[] array = 'ab'.chars assert array.flatten() == ['a', 'b']
- Parameters:
self
- a char Array- Returns:
- a Collection of the array elements
- Since:
- 1.6.0
-
flatten
Flatten a 2D array into a new collection. The items are copied row by row.Example usage:
char[][] array = ['ab'.chars, 'cd'.chars] assert array.flatten() == ['a', 'b', 'c', 'd']
- Parameters:
self
- a 2D char Array- Returns:
- a Collection of the array elements
- Since:
- 5.0.0
-
flatten
Flatten an array. This array is added to a new collection. It is an alias fortoList()
but allows algorithms to be written which also work on multidimensional arrays or non-arrays where flattening would be applicable.short[] array = [0, 1] assert array.flatten() == [0, 1]
- Parameters:
self
- a short Array- Returns:
- a Collection of the array elements
- Since:
- 1.6.0
-
flatten
Flatten a 2D array into a new collection. The items are copied row by row.Example usage:
short[][] array = [[0, 1], [2, 3]] assert array.flatten() == [0, 1, 2, 3]
- Parameters:
self
- a 2D short Array- Returns:
- a Collection of the array elements
- Since:
- 5.0.0
-
flatten
Flatten an array. This array is added to a new collection. It is an alias fortoList()
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]
- Parameters:
self
- an int Array- Returns:
- a Collection of the array elements
- Since:
- 1.6.0
-
flatten
Flatten a 2D array into a new collection. The items are copied row by row.Example usage:
int[][] array = [[0, 1], [2, 3]] assert array.flatten() == [0, 1, 2, 3]
- Parameters:
self
- a 2D int Array- Returns:
- a Collection of the array elements
- Since:
- 5.0.0
-
flatten
Flatten an array. This array is added to a new collection. It is an alias fortoList()
but allows algorithms to be written which also work on multidimensional arrays or non-arrays where flattening would be applicable.long[] array = [0L, 1L] assert array.flatten() == [0L, 1L]
- Parameters:
self
- a long Array to flatten- Returns:
- a Collection of the array elements
- Since:
- 1.6.0
-
flatten
Flatten a 2D array into a new collection. The items are copied row by row.Example usage:
long[][] array = [[0, 1], [2, 3]] assert array.flatten() == [0, 1, 2, 3]
- Parameters:
self
- a 2D long Array- Returns:
- a Collection of the array elements
- Since:
- 5.0.0
-
flatten
Flatten an array. This array is added to a new collection. It is an alias fortoList()
but allows algorithms to be written which also work on multidimensional arrays or non-arrays where flattening would be applicable.float[] array = [0.0f, 1.0f] assert array.flatten() == [0.0f, 1.0f]
- Parameters:
self
- a float Array to flatten- Returns:
- a Collection of the array elements
- Since:
- 1.6.0
-
flatten
Flatten a 2D array into a new collection. The items are copied row by row.Example usage:
float[][] array = [[0.0f, 1.0f], [2.0f, 3.0f]] assert array.flatten() == [0.0f, 1.0f, 2.0f, 3.0f]
- Parameters:
self
- a 2D float Array- Returns:
- a Collection of the array elements
- Since:
- 5.0.0
-
flatten
Flatten an array. This array is added to a new collection. It is an alias fortoList()
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]
- Parameters:
self
- a double Array to flatten- Returns:
- a Collection of the array elements
- Since:
- 1.6.0
-
flatten
Flatten a 2D array into a new collection. The items are copied row by row.Example usage:
double[][] array = [[0.0f, 1.0f], [2.0f, 3.0f]] assert array.flatten() == [0.0f, 1.0f, 2.0f, 3.0f]
- Parameters:
self
- a 2D double Array- Returns:
- a Collection of the array elements
- Since:
- 5.0.0
-
getAt
Support 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:
array
- a boolean arrayrange
- a range indicating the indices for the items to retrieve- Returns:
- list of the retrieved booleans
- Since:
- 1.0
-
getAt
Support the subscript operator for a byte array with a range giving the desired indices.byte[] 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:
array
- a byte arrayrange
- a range indicating the indices for the items to retrieve- Returns:
- list of the retrieved bytes
- Since:
- 1.0
-
getAt
Support the subscript operator for a char array with a range giving the desired indices.char[] array = 'abcdef'.chars assert array[2..<2] == [] // EmptyRange assert array[(0..5.5).step(2)] == ['a', 'c', 'e'] // NumberRange assert array[(1..5.5).step(2)] == ['b', 'd', 'f'] // NumberRange
- Parameters:
array
- a char arrayrange
- a range indicating the indices for the items to retrieve- Returns:
- list of the retrieved chars
- Since:
- 1.5.0
-
getAt
Support the subscript operator for a short array with a range giving the desired indices.short[] 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:
array
- a short arrayrange
- a range indicating the indices for the items to retrieve- Returns:
- list of the retrieved shorts
- Since:
- 1.0
-
getAt
Support 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:
array
- an int arrayrange
- a range indicating the indices for the items to retrieve- Returns:
- list of the ints at the given indices
- Since:
- 1.0
-
getAt
Support the subscript operator for a long array with a range giving the desired indices.long[] array = [1L, 3L, 5L, 7L, 9L, 11L] assert array[2..<2] == [] // EmptyRange assert array[(0..5.5).step(2)] == [1L, 5L, 9L] // NumberRange assert array[(1..5.5).step(2)] == [3L, 7L, 11L] // NumberRange
- Parameters:
array
- a long arrayrange
- a range indicating the indices for the items to retrieve- Returns:
- list of the retrieved longs
- Since:
- 1.0
-
getAt
Support the subscript operator for a float array with a range giving the desired indices.float[] array = [1.0f, 3.0f, 5.0f, 7.0f, 9.0f, 11.0f] assert array[2..<2] == [] // EmptyRange assert array[(0..5.5).step(2)] == [1.0f, 5.0f, 9.0f] // NumberRange assert array[(1..5.5).step(2)] == [3.0f, 7.0f, 11.0f] // NumberRange
- Parameters:
array
- a float arrayrange
- a range indicating the indices for the items to retrieve- Returns:
- list of the retrieved floats
- Since:
- 1.0
-
getAt
Support 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:
array
- a double arrayrange
- a range indicating the indices for the items to retrieve- Returns:
- list of the retrieved doubles
- Since:
- 1.0
-
getAt
Support 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:
array
- a boolean arrayrange
- an IntRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved booleans
- Since:
- 1.0
-
getAt
Support the subscript operator for a byte array with an IntRange giving the desired indices.byte[] 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:
array
- a byte arrayrange
- an IntRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved bytes
- Since:
- 1.0
-
getAt
Support the subscript operator for a char array with an IntRange giving the desired indices.char[] array = 'abcdef'.chars assert array[2..3] == ['c', 'd'] assert array[-2..-1] == ['e', 'f'] assert array[-1..-2] == ['f', 'e']
- Parameters:
array
- a char arrayrange
- an IntRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved chars
- Since:
- 1.0
-
getAt
Support the subscript operator for a short array with an IntRange giving the desired indices.short[] 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:
array
- a short arrayrange
- an IntRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved shorts
- Since:
- 1.0
-
getAt
Support 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:
array
- an int arrayrange
- an IntRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved ints
- Since:
- 1.0
-
getAt
Support the subscript operator for a long array with an IntRange giving the desired indices.long[] array = [0L, 10L, 20L, 30L, 40L] assert array[2..3] == [20L, 30L] assert array[-2..-1] == [30L, 40L] assert array[-1..-2] == [40L, 30L]
- Parameters:
array
- a long arrayrange
- an IntRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved longs
- Since:
- 1.0
-
getAt
Support the subscript operator for a float array with an IntRange giving the desired indices.float[] array = [0.0f, 10.0f, 20.0f, 30.0f, 40.0f] assert array[2..3] == [20.0f, 30.0f] assert array[-2..-1] == [30.0f, 40.0f] assert array[-1..-2] == [40.0f, 30.0f]
- Parameters:
array
- a float arrayrange
- an IntRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved floats
- Since:
- 1.0
-
getAt
Support 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:
array
- a double arrayrange
- an IntRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved doubles
- Since:
- 1.0
-
getAt
Support 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:
array
- a boolean arrayrange
- an ObjectRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved bytes
- Since:
- 1.0
-
getAt
Support the subscript operator for a byte array with an ObjectRange giving the desired indices.byte[] array = [0, 10, 20, 30, 40] def range = new ObjectRange(2, 3) assert array[range] == [20, 30]
- Parameters:
array
- a byte arrayrange
- an ObjectRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved bytes
- Since:
- 1.0
-
getAt
Support the subscript operator for a boolean array with an ObjectRange giving the desired indices.char[] array = 'abcdef'.chars def range = new ObjectRange(2, 3) assert array[range] == ['c', 'd']
- Parameters:
array
- a char arrayrange
- an ObjectRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved chars
- Since:
- 1.0
-
getAt
Support the subscript operator for a short array with an ObjectRange giving the desired indices.short[] array = [0, 10, 20, 30, 40] def range = new ObjectRange(2, 3) assert array[range] == [20, 30]
- Parameters:
array
- a short arrayrange
- an ObjectRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved shorts
- Since:
- 1.0
-
getAt
Support 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:
array
- an int arrayrange
- an ObjectRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved ints
- Since:
- 1.0
-
getAt
Support the subscript operator for a long array with an ObjectRange giving the desired indices.long[] array = [0L, 10L, 20L, 30L, 40L] def range = new ObjectRange(2, 3) assert array[range] == [20L, 30L]
- Parameters:
array
- a long arrayrange
- an ObjectRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved longs
- Since:
- 1.0
-
getAt
Support the subscript operator for a float array with an ObjectRange giving the desired indices.float[] array = [0.0f, 10.0f, 20.0f, 30.0f, 40.0f] def range = new ObjectRange(2, 3) assert array[range] == [20.0f, 30.0f]
- Parameters:
array
- a float arrayrange
- an ObjectRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved floats
- Since:
- 1.0
-
getAt
Support 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:
array
- a double arrayrange
- an ObjectRange indicating the indices for the items to retrieve- Returns:
- list of the retrieved doubles
- Since:
- 1.0
-
getAt
Support 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:
array
- a boolean arrayindices
- a collection of indices for the items to retrieve- Returns:
- list of the booleans at the given indices
- Since:
- 1.0
-
getAt
Support the subscript operator for a byte array with a (potentially nested) collection giving the desired indices.byte[] 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:
array
- a byte arrayindices
- a collection of indices for the items to retrieve- Returns:
- list of the bytes at the given indices
- Since:
- 1.0
-
getAt
Support the subscript operator for a char array with a (potentially nested) collection giving the desired indices.char[] array = 'abcde'.chars assert array[2, 3] == ['c', 'd'] assert array[1, 0..1, [0, [-1]]] == ['b', 'a', 'b', 'a', 'e']
- Parameters:
array
- a char arrayindices
- a collection of indices for the items to retrieve- Returns:
- list of the chars at the given indices
- Since:
- 1.0
-
getAt
Support the subscript operator for a short array with a (potentially nested) collection giving the desired indices.short[] 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:
array
- a short arrayindices
- a collection of indices for the items to retrieve- Returns:
- list of the shorts at the given indices
- Since:
- 1.0
-
getAt
Support 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:
array
- an int arrayindices
- a collection of indices for the items to retrieve- Returns:
- list of the ints at the given indices
- Since:
- 1.0
-
getAt
Support the subscript operator for a long array with a (potentially nested) collection giving the desired indices.long[] array = [0L, 2L, 4L, 6L, 8L] assert array[2, 3] == [4L, 6L] assert array[1, 0..1, [0, [-1]]] == [2L, 0L, 2L, 0L, 8L]
- Parameters:
array
- a long arrayindices
- a collection of indices for the items to retrieve- Returns:
- list of the longs at the given indices
- Since:
- 1.0
-
getAt
Support the subscript operator for a float array with a (potentially nested) collection giving the desired indices.float[] array = [0.0f, 2.0f, 4.0f, 6.0f, 8.0f] assert array[2, 3] == [4.0f, 6.0f] assert array[1, 0..1, [0, [-1]]] == [2.0f, 0.0f, 2.0f, 0.0f, 8.0f]
- Parameters:
array
- a float arrayindices
- a collection of indices for the items to retrieve- Returns:
- list of the floats at the given indices
- Since:
- 1.0
-
getAt
Support 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:
array
- a double arrayindices
- a collection of indices for the items to retrieve- Returns:
- list of the doubles at the given indices
- Since:
- 1.0
-
getIndices
Returns indices of the boolean array.boolean[] array = [false, true] assert array.indices == 0..1
- Since:
- 3.0.8
- See Also:
-
getIndices
Returns indices of the byte array.byte[] array = [0, 1] assert array.indices == 0..1
- Since:
- 3.0.8
- See Also:
-
getIndices
Returns indices of the char array.char[] array = 'ab'.chars assert array.indices == 0..1
- Since:
- 3.0.8
- See Also:
-
getIndices
Returns indices of the short array.short[] array = [0, 1] assert array.indices == 0..1
- Since:
- 3.0.8
- See Also:
-
getIndices
Returns indices of the int array.int[] array = [0, 1] assert array.indices == 0..1
- Since:
- 3.0.8
- See Also:
-
getIndices
Returns indices of the long array.long[] array = [0L, 1L] assert array.indices == 0..1
- Since:
- 3.0.8
- See Also:
-
getIndices
Returns indices of the float array.float[] array = [0.0f, 1.0f] assert array.indices == 0..1
- Since:
- 3.0.8
- See Also:
-
getIndices
Returns indices of the double array.double[] array = [0.0d, 1.0d] assert array.indices == 0..1
- Since:
- 3.0.8
- See Also:
-
head
public static boolean head(boolean[] self) Returns the first item from the boolean array.boolean[] array = [true, false] assert array.head() == true
An alias forfirst()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
head
public static byte head(byte[] self) Returns the first item from the byte array.byte[] bytes = [1, 2, 3] assert bytes.head() == 1
An alias forfirst()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
head
public static char head(char[] self) Returns the first item from the char array.char[] chars = ['a', 'b', 'c'] assert chars.head() == 'a'
An alias forfirst()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
head
public static short head(short[] self) Returns the first item from the short array.short[] shorts = [10, 20, 30] assert shorts.head() == 10
An alias forfirst()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
head
public static int head(int[] self) Returns the first item from the int array.int[] ints = [1, 3, 5] assert ints.head() == 1
An alias forfirst()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
head
public static long head(long[] self) Returns the first item from the long array.long[] longs = [2L, 4L, 6L] assert longs.head() == 2L
An alias forfirst()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
head
public static float head(float[] self) Returns the first item from the float array.float[] floats = [2.0f, 4.0f, 6.0f] assert floats.head() == 2.0f
An alias forfirst()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
head
public static double head(double[] self) Returns the first item from the double array.double[] doubles = [10.0d, 20.0d, 30.0d] assert doubles.head() == 10.0d
An alias forfirst()
.- Parameters:
self
- an array- Returns:
- the first element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
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()
- Since:
- 3.0.8
- See Also:
-
indexed
Zips an int[] with indices in (index, value) order. 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:
self
- an Iterableoffset
- 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:
-
indexed
Zips a long[] with indices in (index, value) order starting from index 0. Example usage:long[] nums = [10L, 20L, 30L] assert [0: 10L, 1: 20L, 2: 30L] == nums.indexed()
- Since:
- 3.0.8
- See Also:
-
indexed
Zips a long[] with indices in (index, value) order. Example usage:long[] nums = [10L, 20L, 30L] assert [5: 10L, 6: 20L, 7: 30L] == nums.indexed(5)
- Parameters:
self
- a long[]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:
-
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:
-
indexed
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:
self
- a double[]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:
-
init
public static boolean[] init(boolean[] self) 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
- Parameters:
self
- an array- Returns:
- an array without its last element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
init
public static byte[] init(byte[] self) Returns the items from the byte array excluding the last item.byte[] bytes = [1, 2, 3] def result = bytes.init() assert result == [1, 2] assert bytes.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its last element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
init
public static char[] init(char[] self) Returns the items from the char array excluding the last item.char[] chars = ['a', 'b', 'c'] def result = chars.init() assert result == ['a', 'b'] assert chars.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its last element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
init
public static short[] init(short[] self) Returns the items from the short array excluding the last item.short[] shorts = [10, 20, 30] def result = shorts.init() assert result == [10, 20] assert shorts.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its last element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
init
public static int[] init(int[] self) 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
- Parameters:
self
- an array- Returns:
- an array without its last element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
init
public static long[] init(long[] self) Returns the items from the long array excluding the last item.long[] longs = [2L, 4L, 6L] def result = longs.init() assert result == [2L, 4L] assert longs.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its last element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
init
public static float[] init(float[] self) Returns the items from the float array excluding the last item.float[] floats = [2.0f, 4.0f, 6.0f] def result = floats.init() assert result == [2.0f, 4.0f] assert floats.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its last element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
init
public static double[] init(double[] self) 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
- Parameters:
self
- an array- Returns:
- an array without its last element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
join
Concatenates the string representation of each item in this array, with the given String as a separator between each item.- Parameters:
self
- an array of booleanseparator
- a String separator- Returns:
- the joined String
- Since:
- 2.4.1
-
join
Concatenates the string representation of each item in this array, with the given String as a separator between each item.- Parameters:
self
- an array of byteseparator
- a String separator- Returns:
- the joined String
- Since:
- 2.4.1
-
join
Concatenates the string representation of each item in this array, with the given String as a separator between each item.- Parameters:
self
- an array of charseparator
- a String separator- Returns:
- the joined String
- Since:
- 2.4.1
-
join
Concatenates the string representation of each item in this array, with the given String as a separator between each item.- Parameters:
self
- an array of shortseparator
- a String separator- Returns:
- the joined String
- Since:
- 2.4.1
-
join
Concatenates the string representation of each item in this array, with the given String as a separator between each item.- Parameters:
self
- an array of intseparator
- a String separator- Returns:
- the joined String
- Since:
- 2.4.1
-
join
Concatenates the string representation of each item in this array, with the given String as a separator between each item.- Parameters:
self
- an array of longseparator
- a String separator- Returns:
- the joined String
- Since:
- 2.4.1
-
join
Concatenates the string representation of each item in this array, with the given String as a separator between each item.- Parameters:
self
- an array of floatseparator
- a String separator- Returns:
- the joined String
- Since:
- 2.4.1
-
join
Concatenates the string representation of each item in this array, with the given String as a separator between each item.- Parameters:
self
- an array of doubleseparator
- a String separator- Returns:
- the joined String
- Since:
- 2.4.1
-
last
public static boolean last(boolean[] self) Returns the last item from the boolean array.boolean[] array = [true, false, true] assert array.last() == true
- Parameters:
self
- an array- Returns:
- the last element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
last
public static byte last(byte[] self) Returns the last item from the byte array.byte[] bytes = [1, 2, 3] assert bytes.last() == 3
- Parameters:
self
- an array- Returns:
- the last element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
last
public static char last(char[] self) Returns the last item from the char array.char[] chars = ['a', 'b', 'c'] assert chars.last() == 'c'
- Parameters:
self
- an array- Returns:
- the last element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
last
public static short last(short[] self) Returns the last item from the short array.short[] shorts = [10, 20, 30] assert shorts.last() == 30
- Parameters:
self
- an array- Returns:
- the last element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
last
public static int last(int[] self) Returns the last item from the int array.int[] ints = [1, 3, 5] assert ints.last() == 5
- Parameters:
self
- an array- Returns:
- the last element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
last
public static long last(long[] self) Returns the last item from the long array.long[] longs = [2L, 4L, 6L] assert longs.last() == 6L
- Parameters:
self
- an array- Returns:
- the last element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
last
public static float last(float[] self) Returns the last item from the float array.float[] floats = [2.0f, 4.0f, 6.0f] assert floats.last() == 6.0f
- Parameters:
self
- an array- Returns:
- the last element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
last
public static double last(double[] self) Returns the last item from the double array.double[] doubles = [10.0d, 20.0d, 30.0d] assert doubles.last() == 30.0d
- Parameters:
self
- an array- Returns:
- the last element
- Throws:
NoSuchElementException
- if the array is empty- Since:
- 5.0.0
-
max
public static int max(int[] self) Adds max() method to int arrays. Example usage:int[] nums = [1, 3, 2] assert 3 == nums.max()
- Parameters:
self
- an int array- Returns:
- the maximum value
- Since:
- 3.0.8
-
max
Selects the maximum value found from the int array using the supplier IntBinaryOperator as a comparator 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() }- Parameters:
self
- an int arraycomparator
- a comparator, i.e. returns a negative value if the first parameter is less than the second- Returns:
- the maximum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
max
Selects the maximum value found from the int array using the supplier 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() }
- Parameters:
self
- an int arrayoperator
- an operator that returns an int used for comparing values- Returns:
- the maximum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
maxBy
Selects the maximum value found from the int array using the closure to determine the maximum of any two values.int[] nums = [30, 45, 60, 90] assert 90 == nums.maxBy{ Math.sin(Math.toRadians(it)) } assert 30 == nums.maxBy{ Math.cos(Math.toRadians(it)) } // cos(90) == 0
If the closure has two parameters it is used like a traditional Comparator, i.e., it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.
- Parameters:
self
- an int arrayclosure
- a Closure used to determine the correct ordering- Returns:
- the maximum value
- Since:
- 5.0.0
- See Also:
-
maxComparing
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:
self
- an int arraycomparator
- a Comparator- Returns:
- the maximum value
- Since:
- 5.0.0
- See Also:
-
max
public static long max(long[] self) Adds max() method to long arrays. Example usage:long[] nums = [1L, 3L, 2L] assert 3L == nums.max()
- Parameters:
self
- a long array- Returns:
- the maximum value
- Since:
- 3.0.8
-
max
Selects the maximum value found from the long array using the supplier LongBinaryOperator as a comparator to determine the maximum of any two values.long[] nums = [10L, 20L, -30L] assert 20L == nums.max{ n, m
->
n<=>
m } assert -30L == nums.max{ n, m->
n.abs()<=>
m.abs() }- Parameters:
self
- a long arraycomparator
- a comparator, i.e. returns a negative value if the first parameter is less than the second- Returns:
- the maximum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
max
Selects the maximum value found from the long array using the supplier LongUnaryOperator to determine the maximum of any two values. The operator is applied to each array element and the results are compared.long[] nums = [10L, 20L, -30L] assert 20L == nums.max{ it } assert -30L == nums.max{ it.abs() }
- Parameters:
self
- a long arrayoperator
- an operator that returns a long used for comparing values- Returns:
- the maximum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
maxBy
Selects the maximum value found from the long array using the closure to determine the maximum of any two values.long[] nums = [-30L, 10L, 20L] assert 20L == nums.maxBy{ a, b
->
a<=>
b } assert -30L == nums.maxBy{ it.abs() }If the closure has two parameters it is used like a traditional Comparator, i.e., it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.
- Parameters:
self
- a long arrayclosure
- a Closure used to determine the correct ordering- Returns:
- the maximum value
- Since:
- 5.0.0
- See Also:
-
maxComparing
Selects the maximum value found from the long array using the comparator to determine the maximum of any two values.long[] nums = [10L, 20L, 30L] assert 30L == nums.maxComparing(Comparator.naturalOrder()) assert 10L == nums.maxComparing(Comparator.reverseOrder())
- Parameters:
self
- a long arraycomparator
- a Comparator- Returns:
- the maximum value
- Since:
- 5.0.0
- See Also:
-
max
public static double max(double[] self) Adds max() method to double arrays. Example usage:double[] nums = [1.1d, 3.3d, 2.2d] assert 3.3d == nums.max()
- Parameters:
self
- a double array- Returns:
- the maximum value
- Since:
- 3.0.8
-
max
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:
self
- a double arraycomparator
- a comparator, i.e. returns a negative value if the first parameter is less than the second- Returns:
- the maximum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
max
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:
self
- a double arrayoperator
- an operator that returns a double used for comparing values- Returns:
- the maximum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
maxBy
Selects the maximum value found from the double array using the closure to determine the maximum of any two values.double[] nums = [-30.0d, 10.0d, 20.0d] assert 20.0d == nums.maxBy{ a, b
->
a<=>
b } assert -30.0d == nums.maxBy{ it.abs() }If the closure has two parameters it is used like a traditional Comparator, i.e., it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.
- Parameters:
self
- a double arrayclosure
- a Closure used to determine the correct ordering- Returns:
- the maximum value
- Since:
- 5.0.0
- See Also:
-
maxComparing
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:
self
- a double arraycomparator
- a Comparator- Returns:
- the maximum value
- Since:
- 5.0.0
- See Also:
-
min
public static int min(int[] self) Adds min() method to int arrays. Example usage:int[] nums = [20, 10, 30] assert 10 == nums.min()
- Parameters:
self
- an int array- Returns:
- the minimum value
- Since:
- 3.0.8
-
min
Selects the minimum value found from the int array using the supplier 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() }- Parameters:
self
- an int arraycomparator
- a comparator, i.e. returns a negative value if the first parameter is less than the second- Returns:
- the minimum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
min
Selects the minimum value found from the int array using the supplier 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 -20L == nums.min{ n
->
n } assert 10L == nums.min{ n->
n.abs() }- Parameters:
self
- an int arrayoperator
- an operator that returns an int used for comparing values- Returns:
- the minimum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
minBy
Selects the minimum value found from the int array using the closure to determine the minimum of any two values.int[] nums = [-20, 10, 30] assert -20 == nums.minBy{ a, b
->
a<=>
b } assert 10 == nums.minBy{ it.abs() }If the closure has two parameters it is used like a traditional Comparator, i.e., it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.
- Parameters:
self
- an int arrayclosure
- a Closure used to determine the correct ordering- Returns:
- the minimum value
- Since:
- 5.0.0
- See Also:
-
minComparing
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:
self
- an int arraycomparator
- a Comparator- Returns:
- the minimum value
- Since:
- 5.0.0
- See Also:
-
min
public static long min(long[] self) Adds min() method to long arrays. Example usage:long[] nums = [20L, 10L, 30L] assert 10L == nums.min()
- Parameters:
self
- a long array- Returns:
- the minimum value
- Since:
- 3.0.8
-
min
Selects the minimum value found from the long array using the supplier LongBinaryOperator as a comparator to determine the minimum of any two values.long[] nums = [10L, -20L, 30L] assert -20L == nums.min{ n, m
->
n<=>
m } assert 10L == nums.min{ n, m->
n.abs()<=>
m.abs() }- Parameters:
self
- a long arraycomparator
- a comparator, i.e. returns a negative value if the first parameter is less than the second- Returns:
- the minimum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
min
Selects the minimum value found from the long array using the supplier LongUnaryOperator to determine the minimum of any two values. The operator is applied to each array element and the results are compared.long[] nums = [10L, -20L, 30L] assert -20L == nums.min{ it } assert 10L == nums.min{ it.abs() }
- Parameters:
self
- a long arrayoperator
- an operator that returns a long used for comparing values- Returns:
- the minimum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
minBy
Selects the minimum value found from the long array using the closure to determine the minimum of any two values.long[] nums = [-20L, 10L, 30L] assert -20L == nums.minBy{ a, b
->
a<=>
b } assert 10L == nums.minBy{ it.abs() }If the closure has two parameters it is used like a traditional Comparator, i.e., it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an int or long) which is then used for further comparison.
- Parameters:
self
- a long arrayclosure
- a Closure used to determine the correct ordering- Returns:
- the minimum value
- Since:
- 5.0.0
- See Also:
-
minComparing
Selects the minimum value found from the long array using the comparator to determine the minimum of any two values.long[] nums = [10L, 20L, 30L] assert 10L == nums.minComparing(Comparator.naturalOrder()) assert 30L == nums.minComparing(Comparator.reverseOrder())
- Parameters:
self
- a long arraycomparator
- a Comparator- Returns:
- the minimum value
- Since:
- 5.0.0
- See Also:
-
min
public static double min(double[] self) Adds min() method to double arrays. Example usage:double[] nums = [20.0d, 10.0d, 30.0d] assert 10.0d == nums.min()
- Parameters:
self
- a double array- Returns:
- the minimum value
- Since:
- 3.0.8
-
min
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:
self
- a double arraycomparator
- a comparator, i.e. returns a negative value if the first parameter is less than the second- Returns:
- the minimum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
min
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:
self
- a double arrayoperator
- an operator that returns a double used for comparing values- Returns:
- the minimum value
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
minBy
Selects the minimum value found from the double array using the closure to determine the minimum of any two values.double[] nums = [-20.0d, 10.0d, 30.0d] assert -20.0d == nums.minBy{ a, b
->
a<=>
b } assert 10.0d == nums.minBy{ it.abs() }If the closure has two parameters it is used like a traditional Comparator, i.e., it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an int or double) which is then used for further comparison.
- Parameters:
self
- a double arrayclosure
- a Closure used to determine the correct ordering- Returns:
- the minimum value
- Since:
- 5.0.0
- See Also:
-
minComparing
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:
self
- a double arraycomparator
- a Comparator- Returns:
- the minimum value
- Since:
- 5.0.0
- See Also:
-
reverse
public static boolean[] reverse(boolean[] self) 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]
- Parameters:
self
- a boolean array- Returns:
- an array containing the reversed items
- Since:
- 5.0.0
- See Also:
-
reverse
public static boolean[] reverse(boolean[] self, boolean mutate) Reverse 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:
self
- a boolean arraymutate
-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
-
reverse
public static byte[] reverse(byte[] self) Creates a new byte array containing items which are the same as this array but in reverse order.byte[] array = 1..2 assert array.reverse() == 2..1
- Parameters:
self
- a byte array- Returns:
- an array containing the reversed items
- Since:
- 5.0.0
- See Also:
-
reverse
public static byte[] reverse(byte[] self, boolean mutate) Reverse 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.byte[] 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:
self
- a byte arraymutate
-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
-
reverse
public static char[] reverse(char[] self) Creates a new char array containing items which are the same as this array but in reverse order.char[] array = ['a', 'b'] assert array.reverse() == ['b', 'a'] as char[]
- Parameters:
self
- a char array- Returns:
- an array containing the reversed items
- Since:
- 5.0.0
- See Also:
-
reverse
public static char[] reverse(char[] self, boolean mutate) Reverse 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.char[] array = ['a', 'b', 'c'] def yarra = array.reverse(true) assert array == ['c', 'b', 'a'] assert yarra == ['c', 'b', 'a'] assert array === yarra yarra = array.reverse(false) assert array !== yarra assert array == ['c', 'b', 'a'] assert yarra == ['a', 'b', 'c']
- Parameters:
self
- a char arraymutate
-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
-
reverse
public static short[] reverse(short[] self) Creates a new short array containing items which are the same as this array but in reverse order.short[] array = 1..2 assert array.reverse() == 2..1
- Parameters:
self
- a short array- Returns:
- an array containing the reversed items
- Since:
- 5.0.0
- See Also:
-
reverse
public static short[] reverse(short[] self, boolean mutate) Reverse 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.short[] 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:
self
- a short arraymutate
-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
-
reverse
public static int[] reverse(int[] self) 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
- Parameters:
self
- an int array- Returns:
- an array containing the reversed items
- Since:
- 5.0.0
- See Also:
-
reverse
public static int[] reverse(int[] self, boolean mutate) Reverse 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:
self
- an int arraymutate
-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
-
reverse
public static long[] reverse(long[] self) Creates a new long array containing items which are the same as this array but in reverse order.long[] array = 1L..2L assert array.reverse() == 2L..1L
- Parameters:
self
- a long array- Returns:
- an array containing the reversed items
- Since:
- 5.0.0
- See Also:
-
reverse
public static long[] reverse(long[] self, boolean mutate) Reverse 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.long[] array = 1L..3L def yarra = array.reverse(true) assert array == 3L..1L assert yarra == 3L..1L assert array === yarra yarra = array.reverse(false) assert array !== yarra assert array == 3L..1L assert yarra == 1L..3L
- Parameters:
self
- a long arraymutate
-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
-
reverse
public static float[] reverse(float[] self) Creates a new float array containing items which are the same as this array but in reverse order.float[] array = [1f, 2f] assert array.reverse() == [2f, 1f]
- Parameters:
self
- a float array- Returns:
- an array containing the reversed items
- Since:
- 5.0.0
- See Also:
-
reverse
public static float[] reverse(float[] self, boolean mutate) Reverse 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.float[] array = 1f..3f def yarra = array.reverse(true) assert array == 3f..1f assert yarra == 3f..1f assert array === yarra yarra = array.reverse(false) assert array !== yarra assert array == 3f..1f assert yarra == 1f..3f
- Parameters:
self
- a float arraymutate
-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
-
reverse
public static double[] reverse(double[] self) 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]
- Parameters:
self
- a double array- Returns:
- an array containing the reversed items
- Since:
- 5.0.0
- See Also:
-
reverse
public static double[] reverse(double[] self, boolean mutate) Reverse 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:
self
- a double arraymutate
-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
-
reverseEach
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:
self
- the boolean array over which we iterateclosure
- the closure applied on each boolean- Returns:
- the self array
- Since:
- 5.0.0
-
reverseEach
Iterates through a byte[] in reverse order passing each byte to the given closure.byte[] array = [0, 1, 2] String result = '' array.reverseEach{ result += it } assert result == '210'
- Parameters:
self
- the byte array over which we iterateclosure
- the closure applied on each byte- Returns:
- the self array
- Since:
- 5.0.0
-
reverseEach
Iterates through a char[] in reverse order passing each char to the given closure.char[] array = 'abc'.chars String result = '' array.reverseEach{ result += it } assert result == 'cba'
- Parameters:
self
- the char array over which we iterateclosure
- the closure applied on each char- Returns:
- the self array
- Since:
- 5.0.0
-
reverseEach
Iterates through a short[] in reverse order passing each short to the given closure.short[] array = [0, 1, 2] String result = '' array.reverseEach{ result += it } assert result == '210'
- Parameters:
self
- the short array over which we iterateclosure
- the closure applied on each short- Returns:
- the self array
- Since:
- 5.0.0
-
reverseEach
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:
self
- the int array over which we iterateclosure
- the closure applied on each int- Returns:
- the self array
- Since:
- 5.0.0
-
reverseEach
Iterates through a long[] in reverse order passing each long to the given closure.long[] array = [0, 1, 2] String result = '' array.reverseEach{ result += it } assert result == '210'
- Parameters:
self
- the long array over which we iterateclosure
- the closure applied on each long- Returns:
- the self array
- Since:
- 5.0.0
-
reverseEach
Iterates through a float[] in reverse order passing each float to the given closure.float[] array = [0, 1, 2] String result = '' array.reverseEach{ result += it } assert result == '2.01.00.0'
- Parameters:
self
- the float array over which we iterateclosure
- the closure applied on each float- Returns:
- the self array
- Since:
- 5.0.0
-
reverseEach
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:
self
- the double array over which we iterateclosure
- the closure applied on each double- Returns:
- the self array
- Since:
- 5.0.0
-
size
public static int size(boolean[] array) Provide arrays with asize
method similar to collections.boolean[] array = [true, false, true] assert array.size() == 3
- Parameters:
array
- a boolean array- Returns:
- the length of the array
- Since:
- 1.5.0
- See Also:
-
size
public static int size(byte[] array) Provide arrays with asize
method similar to collections.- Parameters:
array
- a byte array- Returns:
- the length of the array
- Since:
- 1.0
- See Also:
-
size
public static int size(char[] array) Provide arrays with asize
method similar to collections.- Parameters:
array
- a char array- Returns:
- the length of the array
- Since:
- 1.0
- See Also:
-
size
public static int size(short[] array) Provide arrays with asize
method similar to collections.- Parameters:
array
- a short array- Returns:
- the length of the array
- Since:
- 1.0
- See Also:
-
size
public static int size(int[] array) Provide arrays with asize
method similar to collections.- Parameters:
array
- an int array- Returns:
- the length of the array
- Since:
- 1.0
- See Also:
-
size
public static int size(long[] array) Provide arrays with asize
method similar to collections.- Parameters:
array
- a long array- Returns:
- the length of the array
- Since:
- 1.0
- See Also:
-
size
public static int size(float[] array) Provide arrays with asize
method similar to collections.- Parameters:
array
- a float array- Returns:
- the length of the array
- Since:
- 1.0
- See Also:
-
size
public static int size(double[] array) Provide arrays with asize
method similar to collections.- Parameters:
array
- a double array- Returns:
- the length of the array
- Since:
- 1.0
- See Also:
-
sum
public static byte sum(byte[] self) Sums the items in an array.assert (1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum()
- Parameters:
self
- The array of values to add together- Returns:
- The sum of all the items
- Since:
- 2.4.2
-
sum
public static char sum(char[] self) Sums the items in an array.assert (1+2+3+4 as char) == ([1,2,3,4] as char[]).sum()
- Parameters:
self
- The array of values to add together- Returns:
- The sum of all the items
- Since:
- 2.4.2
-
sum
public static short sum(short[] self) Sums the items in an array.assert (1+2+3+4 as short) == ([1,2,3,4] as short[]).sum()
- Parameters:
self
- The array of values to add together- Returns:
- The sum of all the items
- Since:
- 2.4.2
-
sum
public static int sum(int[] self) Sums the items in an array.assert 1+2+3+4 == ([1,2,3,4] as int[]).sum()
- Parameters:
self
- The array of values to add together- Returns:
- The sum of all the items
- Since:
- 2.4.2
-
sum
public static long sum(long[] self) Sums the items in an array.assert (1+2+3+4 as long) == ([1,2,3,4] as long[]).sum()
- Parameters:
self
- The array of values to add together- Returns:
- The sum of all the items
- Since:
- 2.4.2
-
sum
public static float sum(float[] self) Sums the items in an array.assert (1+2+3+4 as float) == ([1,2,3,4] as float[]).sum()
- Parameters:
self
- The array of values to add together- Returns:
- The sum of all the items
- Since:
- 2.4.2
-
sum
public static double sum(double[] self) Sums the items in an array.assert (1+2+3+4 as double) == ([1,2,3,4] as double[]).sum()
- Parameters:
self
- The array of values to add together- Returns:
- The sum of all the items
- Since:
- 2.4.2
-
sum
public static byte sum(byte[] self, byte initialValue) Sums the items in an array, adding the result to some initial value.assert (5+1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum(5 as byte)
- Parameters:
self
- an array of values to suminitialValue
- the items in the array will be summed to this initial value- Returns:
- The sum of all the items.
- Since:
- 2.4.2
-
sum
public static char sum(char[] self, char initialValue) Sums the items in an array, adding the result to some initial value.assert (5+1+2+3+4 as char) == ([1,2,3,4] as char[]).sum(5 as char)
- Parameters:
self
- an array of values to suminitialValue
- the items in the array will be summed to this initial value- Returns:
- The sum of all the items.
- Since:
- 2.4.2
-
sum
public static short sum(short[] self, short initialValue) Sums the items in an array, adding the result to some initial value.assert (5+1+2+3+4 as short) == ([1,2,3,4] as short[]).sum(5 as short)
- Parameters:
self
- an array of values to suminitialValue
- the items in the array will be summed to this initial value- Returns:
- The sum of all the items.
- Since:
- 2.4.2
-
sum
public static int sum(int[] self, 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:
self
- an array of values to suminitialValue
- the items in the array will be summed to this initial value- Returns:
- The sum of all the items.
- Since:
- 2.4.2
-
sum
public static long sum(long[] self, long initialValue) Sums the items in an array, adding the result to some initial value.assert (5+1+2+3+4 as long) == ([1,2,3,4] as long[]).sum(5)
- Parameters:
self
- an array of values to suminitialValue
- the items in the array will be summed to this initial value- Returns:
- The sum of all the items.
- Since:
- 2.4.2
-
sum
public static float sum(float[] self, float initialValue) Sums the items in an array, adding the result to some initial value.assert (5+1+2+3+4 as float) == ([1,2,3,4] as float[]).sum(5)
- Parameters:
self
- an array of values to suminitialValue
- the items in the array will be summed to this initial value- Returns:
- The sum of all the items.
- Since:
- 2.4.2
-
sum
public static double sum(double[] self, 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:
self
- an array of values to suminitialValue
- the items in the array will be summed to this initial value- Returns:
- The sum of all the items.
- Since:
- 2.4.2
-
swap
public static boolean[] swap(boolean[] self, 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:
self
- a boolean arrayi
- a positionj
- a position- Returns:
- self
- Since:
- 2.4.0
-
swap
public static byte[] swap(byte[] self, int i, int j) Swaps two elements at the specified positions.Example:
assert ([1, 3, 2, 4] as byte[]) == ([1, 2, 3, 4] as byte[]).swap(1, 2)
- Parameters:
self
- a boolean arrayi
- a positionj
- a position- Returns:
- self
- Since:
- 2.4.0
-
swap
public static char[] swap(char[] self, int i, int j) Swaps two elements at the specified positions.Example:
assert ([1, 3, 2, 4] as char[]) == ([1, 2, 3, 4] as char[]).swap(1, 2)
- Parameters:
self
- a boolean arrayi
- a positionj
- a position- Returns:
- self
- Since:
- 2.4.0
-
swap
public static short[] swap(short[] self, int i, int j) Swaps two elements at the specified positions.Example:
assert ([1, 3, 2, 4] as short[]) == ([1, 2, 3, 4] as short[]).swap(1, 2)
- Parameters:
self
- a boolean arrayi
- a positionj
- a position- Returns:
- self
- Since:
- 2.4.0
-
swap
public static int[] swap(int[] self, 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:
self
- a boolean arrayi
- a positionj
- a position- Returns:
- self
- Since:
- 2.4.0
-
swap
public static long[] swap(long[] self, int i, int j) Swaps two elements at the specified positions.Example:
assert ([1, 3, 2, 4] as long[]) == ([1, 2, 3, 4] as long[]).swap(1, 2)
- Parameters:
self
- a boolean arrayi
- a positionj
- a position- Returns:
- self
- Since:
- 2.4.0
-
swap
public static float[] swap(float[] self, int i, int j) Swaps two elements at the specified positions.Example:
assert ([1, 3, 2, 4] as float[]) == ([1, 2, 3, 4] as float[]).swap(1, 2)
- Parameters:
self
- a boolean arrayi
- a positionj
- a position- Returns:
- self
- Since:
- 2.4.0
-
swap
public static double[] swap(double[] self, 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:
self
- a boolean arrayi
- a positionj
- a position- Returns:
- self
- Since:
- 2.4.0
-
tail
public static boolean[] tail(boolean[] self) 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
- Parameters:
self
- an array- Returns:
- an array without its first element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
tail
public static byte[] tail(byte[] self) Returns the items from the byte array excluding the first item.byte[] bytes = [1, 2, 3] def result = bytes.tail() assert result == [2, 3] assert bytes.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its first element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
tail
public static char[] tail(char[] self) Returns the items from the char array excluding the first item.char[] chars = ['a', 'b', 'c'] def result = chars.tail() assert result == ['b', 'c'] assert chars.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its first element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
tail
public static short[] tail(short[] self) Returns the items from the short array excluding the first item.short[] shorts = [10, 20, 30] def result = shorts.tail() assert result == [20, 30] assert shorts.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its first element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
tail
public static int[] tail(int[] self) 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
- Parameters:
self
- an array- Returns:
- an array without its first element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
tail
public static long[] tail(long[] self) Returns the items from the long array excluding the first item.long[] longs = [2L, 4L, 6L] def result = longs.tail() assert result == [4L, 6L] assert longs.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its first element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
tail
public static float[] tail(float[] self) Returns the items from the float array excluding the first item.float[] floats = [2.0f, 4.0f, 6.0f] def result = floats.tail() assert result == [4.0f, 6.0f] assert floats.class.componentType == result.class.componentType
- Parameters:
self
- an array- Returns:
- an array without its first element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
tail
public static double[] tail(double[] self) 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
- Parameters:
self
- an array- Returns:
- an array without its first element
- Throws:
UnsupportedOperationException
- if the array is empty- Since:
- 5.0.0
-
toList
Converts this array to a List of the same size, with each element added to the list.- Parameters:
array
- a boolean array- Returns:
- a list containing the contents of this array.
- Since:
- 1.6.0
-
toList
Converts this array to a List of the same size, with each element added to the list.- Parameters:
array
- a byte array- Returns:
- a list containing the contents of this array.
- Since:
- 1.0
-
toList
Converts this array to a List of the same size, with each element added to the list.- Parameters:
array
- a char array- Returns:
- a list containing the contents of this array.
- Since:
- 1.0
-
toList
Converts this array to a List of the same size, with each element added to the list.- Parameters:
array
- a short array- Returns:
- a list containing the contents of this array.
- Since:
- 1.0
-
toList
Converts this array to a List of the same size, with each element added to the list.- Parameters:
array
- an int array- Returns:
- a list containing the contents of this array.
- Since:
- 1.0
-
toList
Converts this array to a List of the same size, with each element added to the list.- Parameters:
array
- a long array- Returns:
- a list containing the contents of this array.
- Since:
- 1.0
-
toList
Converts this array to a List of the same size, with each element added to the list.- Parameters:
array
- a float array- Returns:
- a list containing the contents of this array.
- Since:
- 1.0
-
toList
Converts this array to a List of the same size, with each element added to the list.- Parameters:
array
- a double array- Returns:
- a list containing the contents of this array.
- Since:
- 1.0
-
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
- Parameters:
array
- a boolean array- Returns:
- a set containing the unique contents of this array.
- Since:
- 1.8.0
-
toSet
Converts this array to a Set, with each unique element added to the set.byte[] array = [1, 2, 3, 2, 1] Set expected = [1, 2, 3] assert array.toSet() == expected
- Parameters:
array
- a byte array- Returns:
- a set containing the unique contents of this array.
- Since:
- 1.8.0
-
toSet
Converts this array to a Set, with each unique element added to the set.char[] array = 'xyzzy'.chars Set expected = ['x', 'y', 'z'] assert array.toSet() == expected
- Parameters:
array
- a char array- Returns:
- a set containing the unique contents of this array.
- Since:
- 1.8.0
-
toSet
Converts this array to a Set, with each unique element added to the set.short[] array = [1, 2, 3, 2, 1] Set expected = [1, 2, 3] assert array.toSet() == expected
- Parameters:
array
- a short array- Returns:
- a set containing the unique contents of this array.
- Since:
- 1.8.0
-
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
- Parameters:
array
- an int array- Returns:
- a set containing the unique contents of this array.
- Since:
- 1.8.0
-
toSet
Converts this array to a Set, with each unique element added to the set.long[] array = [1, 2, 3, 2, 1] Set expected = [1, 2, 3] assert array.toSet() == expected
- Parameters:
array
- a long array- Returns:
- a set containing the unique contents of this array.
- Since:
- 1.8.0
-
toSet
Converts this array to a Set, with each unique element added to the set.float[] array = [1.0f, 2.0f, 3.0f, 2.0f, 1.0f] Set expected = [1.0f, 2.0f, 3.0f] assert array.toSet() == expected
- Parameters:
array
- a float array- Returns:
- a set containing the unique contents of this array.
- Since:
- 1.8.0
-
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
- Parameters:
array
- a double array- Returns:
- a set containing the unique contents of this array.
- Since:
- 1.8.0
-
toString
Returns the string representation of the given array.boolean[] array = [false, true, false] assert array.toString() == '[false, true, false]'
- Parameters:
self
- an array- Returns:
- the string representation
- Since:
- 1.6.0
-
toString
Returns the string representation of the given array.byte[] array = [1, 2, 3, 2, 1] assert array.toString() == '[1, 2, 3, 2, 1]'
- Parameters:
self
- an array- Returns:
- the string representation
- Since:
- 1.6.0
-
toString
Returns the string representation of the given array.char[] array = 'abcd'.chars assert array instanceof char[] assert array.toString() == 'abcd'
- Parameters:
self
- an array- Returns:
- the string representation
- Since:
- 1.6.0
-
toString
Returns the string representation of the given array.short[] array = [1, 2, 3, 2, 1] assert array.toString() == '[1, 2, 3, 2, 1]'
- Parameters:
self
- an array- Returns:
- the string representation
- Since:
- 1.6.0
-
toString
Returns the string representation of the given array.int[] array = [1, 2, 3, 2, 1] assert array.toString() == '[1, 2, 3, 2, 1]'
- Parameters:
self
- an array- Returns:
- the string representation
- Since:
- 1.6.0
-
toString
Returns the string representation of the given array.long[] array = [1, 2, 3, 2, 1] assert array.toString() == '[1, 2, 3, 2, 1]'
- Parameters:
self
- an array- Returns:
- the string representation
- Since:
- 1.6.0
-
toString
Returns the string representation of the given array.float[] array = [1, 2, 3, 2, 1] assert array.toString() == '[1.0, 2.0, 3.0, 2.0, 1.0]'
- Parameters:
self
- an array- Returns:
- the string representation
- Since:
- 1.6.0
-
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]'
- Parameters:
self
- an array- Returns:
- the string representation
- Since:
- 1.6.0
-
transpose
public static boolean[][] transpose(boolean[][] self) A transpose method for 2D boolean arrays.Example usage:
boolean[][] array = [[false, false], [true, true]] boolean[][] expected = [[false, true], [false, true]] def result = array.transpose() assert result == expected assert array.class.componentType == result.class.componentType
- Parameters:
self
- a 2D boolean array- Returns:
- the transposed 2D boolean array
- Since:
- 5.0.0
-
transpose
public static byte[][] transpose(byte[][] self) A transpose method for 2D byte arrays.Example usage:
byte[][] bytes = [[1, 10], [2, 20]] byte[][] expected = [[1, 2], [10, 20]] def result = bytes.transpose() assert result == expected assert bytes.class.componentType == result.class.componentType
- Parameters:
self
- a 2D byte array- Returns:
- the transposed 2D byte array
- Since:
- 5.0.0
-
transpose
public static char[][] transpose(char[][] self) A transpose method for 2D char arrays.Example usage:
char[][] chars = [['a', 'b'], ['A', 'B']] char[][] expected = [['a', 'A'], ['b', 'B']] def result = chars.transpose() assert result == expected assert chars.class.componentType == result.class.componentType
- Parameters:
self
- a 2D char array- Returns:
- the transposed 2D char array
- Since:
- 5.0.0
-
transpose
public static short[][] transpose(short[][] self) A transpose method for 2D short arrays.Example usage:
short[][] shorts = [[1, 10], [100, 1000]] short[][] expected = [[1, 100], [10, 1000]] def result = shorts.transpose() assert result == expected assert shorts.class.componentType == result.class.componentType
- Parameters:
self
- a 2D short array- Returns:
- the transposed 2D short array
- Since:
- 5.0.0
-
transpose
public static int[][] transpose(int[][] self) A transpose method for 2D int arrays.Example usage:
int[][] nums = [[10, 15, 20], [30, 35, 40]] int[][] expected = [[10, 30], [15, 35], [20, 40]] assert nums.transpose() == expected
- Parameters:
self
- a 2D int array- Returns:
- the transposed 2D int array
- Since:
- 3.0.8
-
transpose
public static long[][] transpose(long[][] self) A transpose method for 2D long arrays.Example usage:
long[][] longs = [[1L, 3L, 5L], [2L, 4L, 6L]] long[][] expected = [[1L, 2L], [3L, 4L], [5L, 6L]] def result = longs.transpose() assert result == expected assert longs.class.componentType == result.class.componentType
- Parameters:
self
- a 2D long array- Returns:
- the transposed 2D long array
- Since:
- 3.0.8
-
transpose
public static float[][] transpose(float[][] self) A transpose method for 2D float arrays.Example usage:
float[][] floats = [[1.0f, 10.0f], [2.0f, 20.0f]] float[][] expected = [[1.0f, 2.0f], [10.0f, 20.0f]] def result = floats.transpose() assert result == expected assert floats.class.componentType == result.class.componentType
- Parameters:
self
- a 2D float array- Returns:
- the transposed 2D float array
- Since:
- 5.0.0
-
transpose
public static double[][] transpose(double[][] self) A transpose method for 2D double arrays.Example usage:
double[][] doubles = [[1.0d, 10.0d], [2.0d, 20.0d]] double[][] expected = [[1.0d, 2.0d], [10.0d, 20.0d]] def result = doubles.transpose() assert result == expected assert doubles.class.componentType == result.class.componentType
- Parameters:
self
- a 2D double array- Returns:
- the transposed 2D double array
- Since:
- 3.0.8
-