Class ArrayUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CNumber[]
applyTransform
(double[] src, Function<Double, CNumber> opp) Applies a transform to an array.static double[]
applyTransform
(double[] src, UnaryOperator<Double> opp) Applies a transform to an array.static double[]
applyTransform
(CNumber[] src, Function<CNumber, Double> opp) Applies a transform to an array.static <T> T[]
applyTransform
(T[] src, UnaryOperator<T> opp) Applies a transform to an array.static void
Performs an array copy similar toSystem.arraycopy(Object, int, Object, int, int)
but creates a deep copy of each element in the source array.static double[]
asDouble
(int[] src, double[] dest) Converts an array of ints to an array of doubles.static double[]
Converts an array ofIntegers
to an array of doubles.static Double[]
boxed
(double[] src) Converts a primitive array to an array of equivalent boxed type.static Integer[]
boxed
(int[] src) Converts a primitive array to an array of equivalent boxed type.static boolean
contains
(double[] arr, double key) Checks if an array contains a specified value.static boolean[]
contains
(double[] src, double... keys) Checks if a set of keys are in an array.static boolean
contains
(int[] arr, int key) Checks if an array contains a specified value.static boolean[]
contains
(int[] src, int... keys) Checks if a set of keys is in an array.static CNumber[]
copy2CNumber
(double[] src, CNumber[] dest) Converts array to an array ofcomplex numbers
.static CNumber[]
copy2CNumber
(int[] src, CNumber[] dest) Converts array to an array ofcomplex numbers
.static CNumber[]
copy2CNumber
(Double[] src, CNumber[] dest) Converts array to an array ofcomplex numbers
.static CNumber[]
copy2CNumber
(Integer[] src, CNumber[] dest) Converts array to an array ofcomplex numbers
.static CNumber[]
copy2CNumber
(String[] src, CNumber[] dest) Converts array to an array ofcomplex numbers
.createUniqueMapping
(int[] arr) Creates a mapping of unique values in {code arr} to integers such that each unique value is mapped to a unique integer and those integers range from0
tonumUnique(arr) - 1
.static int[][]
deepCopy
(int[][] src, int[][] dest) Creates a deep copy of a 2D array.static boolean
Checks if a double array is numerically equal to acomplex number
array.static void
fill
(double[][] dest, double fillValue) Fills an array with the specified value;static void
Fills an array with specified value.static void
Fills an array with specified value.static void
Fills range of an array with specified value.static void
Fills an array with specified value.static int[]
filledArray
(int size, int value) Constructs an array filled with a specific value.static void
Fills an array of complex numbers with zeros.static int[]
findFirstLast
(int[] src, int key) Finds the first and last index of a specified key within a sorted array.static double[]
flatten
(double[][] src) Flattens a two-dimensional array.static int[]
flatten
(int[][] src) Flattens a two-dimensional array.static CNumber[]
Flattens a two-dimensional array.static double[]
fromDoubleList
(List<Double> src) Converts a list ofDoubles
objects to a primitive array.static int[]
fromIntegerList
(List<Integer> src) Converts a list ofInteger
objects to a primitive array.static int[]
fromIntegerList
(List<Integer> src, int[] dest) Converts a list ofInteger
objects to a primitive array.static <T> T[]
Converts a list to an array.static int
indexOf
(int[] arr, int key) Finds the fist index of the specifiedkey
within an array.static int[]
intRange
(int start, int end) Gets an array filled with integers fromstart
(inclusive) toend
(exclusive)static int[]
intRange
(int start, int end, int stride) Gets an array filled with integers fromstart
(inclusive) toend
(exclusive) where each int is repeatedstride
times.static double[]
join
(double[] src1, double[] src2) Joins two arrays together.static int[]
join
(int[] src1, int[] src2) Joins two arrays together.static boolean
notContains
(int[] src, int key) Checks if a key is in an array.static int[]
notInAxes
(int[] srcAxes, int dim) Given a list of integers,srcAxes
, which is a subset of{0, 1, 2, ...., dim-1}
in no particular order, compute the integers which are in{0, 1, 2, ...., dim-1}
but not insrcAxes
.static int
numUnique
(double[] arr) Counts the number of unique elements in an array.static int
numUnique
(int[] arr) Counts the number of unique elements in an array.static double[]
range
(int start, int end) Gets an array filled with integers fromstart
(inclusive) toend
(exclusive)static int[]
repeat
(int numTimes, int[] src) Repeats an array a specified number of times.static int[]
shift
(int shift, int[] indices) Shifts all indices in an array by a specified amount.static int[]
shiftRange
(int shift, int[] indices, int start, int stop) Shifts a range of indices in an array by a specified amount.static double[]
splice
(double[] arr1, double[] arr2, int spliceIdx) Splices an array into another array at the specified index.static CNumber[]
Splices an array into another array at the specified index.static int[]
splice
(int[] arr1, int[] arr2, int spliceIdx) Splices an array into another array at the specified index.static double[]
Splices an array into a list at the specified index.static int[]
Splices an array into a list at the specified index.static CNumber[]
Splices an array into a list at the specified index.static CNumber[]
Splices an array into another array at the specified index.static CNumber[]
Splices an array into another array at the specified index.static CNumber[]
spliceDouble
(List<CNumber> list, double[] arr, int spliceIdx) Splices an array into a list at the specified index.static void
stridedFillZeros
(double[] dest, int start, int stride) Fills an array with zeros separated by the given stride.static void
stridedFillZeros
(double[] dest, int start, int length, int stride) Fills an array with a range of zeros, each separated by the given stride.static void
stridedFillZeros
(CNumber[] dest, int start, int stride) Fills an array with zeros separated by the given stride.static void
stridedFillZeros
(CNumber[] dest, int start, int length, int stride) Fills an array with a range of zeros, each separated by the given stride.static void
swap
(double[] arr, int i, int j) Swaps to elements in an array.static void
swap
(int[] src, int[] indices) Swaps elements in an array according to a specified permutation.static void
swap
(int[] arr, int i, int j) Swaps to elements in an array.static void
Swaps to elements in an array.static void
swapUnsafe
(int[] src, int[] indices) Swaps elements in an array according to a specified permutation.toArrayList
(double[] src) Converts an array of doubles to anarray list
.toArrayList
(int[] src) Converts an array of doubles to anarray list
.toArrayList
(CNumber[] src) Converts an array of complex numbers to anarray list
.toComplexArrayList
(double[] src) Converts an array of doubles to a complexarray list
.static double[]
Converts an array ofDouble
objects to a primitive array (i.e.static int[]
Converts an array ofInteger
objects to a primitive array (i.e.static double[]
unboxFlatten
(Double[][] src) Flattens a two-dimensional array and unboxes.static int[]
uniqueSorted
(int[] src) Gets the unique values from an array and sorts them.
-
Constructor Details
-
ArrayUtils
private ArrayUtils()
-
-
Method Details
-
deepCopy
public static int[][] deepCopy(int[][] src, int[][] dest) Creates a deep copy of a 2D array. Assumes arrays are not jagged.- Parameters:
src
- Source array to copy.dest
- Destination array of copy. Ifnull
, a new array will be initialized.- Returns:
- A reference to
dest
if it was notnull
. In the case wheredest
isnull
, then a new array will be initialized and returned. - Throws:
IllegalArgumentException
- If the two arrays are not the same shape.
-
copy2CNumber
Converts array to an array ofcomplex numbers
.- Parameters:
src
- Array to convert.dest
- Destination array. If the destination array is null, a new array will be created.- Returns:
- A reference to the
dest
array. - Throws:
IllegalArgumentException
- If source and destination arrays do not have the same length.
-
copy2CNumber
Converts array to an array ofcomplex numbers
.- Parameters:
src
- Array to convert.dest
- Destination array. If the destination array is null, a new array will be created.- Returns:
- A reference to the
dest
array. - Throws:
IllegalArgumentException
- If source and destination arrays do not have the same length.
-
copy2CNumber
Converts array to an array ofcomplex numbers
.- Parameters:
src
- Array to convert.dest
- Destination array. If the destination array is null, a new array will be created.- Returns:
- A reference to the
dest
array. - Throws:
IllegalArgumentException
- If source and destination arrays do not have the same length.
-
copy2CNumber
Converts array to an array ofcomplex numbers
.- Parameters:
src
- Array to convert.dest
- Destination array. If the destination array is null, a new array will be created.- Returns:
- A reference to the
dest
array. - Throws:
IllegalArgumentException
- If source and destination arrays do not have the same length.
-
copy2CNumber
Converts array to an array ofcomplex numbers
.- Parameters:
src
- Array to convert.dest
- Destination array. If the destination array is null, a new array will be created.- Returns:
- A reference to the
dest
array. - Throws:
IllegalArgumentException
- If source and destination arrays do not have the same length.
-
arraycopy
Performs an array copy similar toSystem.arraycopy(Object, int, Object, int, int)
but creates a deep copy of each element in the source array.- Parameters:
src
- The source array.srcPos
- The starting position from which to copy elements of the source array.dest
- The destination array for the copy.destPos
- Starting index to place copied elements in the destination array.length
- The number of array elements to be copied.- Throws:
ArrayIndexOutOfBoundsException
- If the destPos parameter plus the length parameter exceeds the length of the source array length or the destination array length.
-
fillZeros
Fills an array of complex numbers with zeros.- Parameters:
dest
- Array to fill with zeros.
-
stridedFillZeros
public static void stridedFillZeros(double[] dest, int start, int stride) Fills an array with zeros separated by the given stride.
If
stride=3
,start=1
, anddest={1, 2, 3, 4, 5, 6, 7, 8, 9}
then the result will be{1, 0, 3, 4, 0, 6, 7, 0, 9}
.- Parameters:
dest
- Array to fill with strided zeros.start
- Staring point in array to apply strided zero fill.stride
- Number of elements between each value to set to zero within the destination array.- Throws:
IllegalArgumentException
- If stride is less than 1.IllegalArgumentException
- If start is less than 0.
-
stridedFillZeros
Fills an array with zeros separated by the given stride.
If
stride=3
,start=1
, anddest={1, 2, 3, 4, 5, 6, 7, 8, 9}
then the result will be{1, 0, 3, 4, 0, 6, 7, 0, 9}
.- Parameters:
dest
- Array to fill with strided zeros.start
- Staring point in array to apply strided zero fill.stride
- Number of elements between each value to set to zero within the destination array.- Throws:
IllegalArgumentException
- If stride is less than 1.IllegalArgumentException
- If start is less than 0.
-
stridedFillZeros
Fills an array with a range of zeros, each separated by the given stride. Specifically, the destination array will be filled with several sequential ranges of zeros of specified length. Each range of zeros will be separated by the stride.
If
stride=2
,length=3
,start=1
, anddest={1, 2, 3, 4, 5, 6, 7, 8, 9}
then the result will be {1, 0, 0, 0, 5, 0, 0, 0, 9}.- Parameters:
dest
- Array to fill with strided zeros.start
- Starting point to apply strided zero fill.length
- Number of sequential zeros to fill per stride.stride
- Number of elements between each value to set to zero within the destination array.- Throws:
IllegalArgumentException
- If stride or length is less than one.IllegalArgumentException
- If start is less than zero.
-
stridedFillZeros
public static void stridedFillZeros(double[] dest, int start, int length, int stride) Fills an array with a range of zeros, each separated by the given stride. Specifically, the destination array will be filled with several sequential ranges of zeros of specified length. Each range of zeros will be separated by the stride.
If
stride=2
,length=3
,start=1
, anddest={1, 2, 3, 4, 5, 6, 7, 8, 9}
then the result will be {1, 0, 0, 0, 5, 0, 0, 0, 9}.- Parameters:
dest
- Array to fill with strided zeros.start
- Starting point to apply strided zero fill.length
- Number of sequential zeros to fill per stride.stride
- Number of elements between each value to set to zero within the destination array.- Throws:
IllegalArgumentException
- If stride or length is less than one.IllegalArgumentException
- If start is less than zero.
-
fill
Fills an array with specified value.- Parameters:
dest
- Array to fill.fillValue
- Value to fill array with.
-
fill
-
fill
Fills range of an array with specified value.- Parameters:
dest
- Array to fill.fillValue
- Value to fill array with.from
- Staring index of range (inclusive).to
- Ending index of range (exclusive).
-
fill
Fills an array with specified value. Similar toArrays.fill(Object[], Object)
but creates deep copy of the fill value for each position.- Parameters:
dest
- Array to fill.start
- Starting index of range to fill (Inclusive).end
- Ending index of range to fill (Exclusive).fillValue
- Value to fill array with. Each index of thedest
array will be filled with a deep copy of this value.- Throws:
ArrayIndexOutOfBoundsException
- Ifstart
orend
is not within the destination array.
-
fill
public static void fill(double[][] dest, double fillValue) Fills an array with the specified value;- Parameters:
dest
- Array to fill.fillValue
- Value to fill array with.
-
toArrayList
Converts an array of doubles to anarray list
.- Parameters:
src
- Array to convert.- Returns:
- An equivalent array list.
-
toArrayList
Converts an array of complex numbers to anarray list
.- Parameters:
src
- Array to convert.- Returns:
- An equivalent array list.
-
toComplexArrayList
Converts an array of doubles to a complexarray list
.- Parameters:
src
- Array to convert.- Returns:
- An equivalent complex array list.
-
toArrayList
Converts an array of doubles to anarray list
.- Parameters:
src
- Array to convert.- Returns:
- An equivalent array list.
-
fromDoubleList
-
fromIntegerList
-
fromIntegerList
Converts a list ofInteger
objects to a primitive array.- Parameters:
src
- Source list to convert.dest
- Destination array to store values fromsrc
in (modified). Must be at least as large assrc
.- Returns:
- A reference to the
dest
array.
-
fromList
Converts a list to an array.- Parameters:
src
- Source list to convert.dest
- Destination array to store values fromsrc
in (modified). Must be at least as large assrc
.- Returns:
- A reference to the
dest
array. - Throws:
IllegalArgumentException
- If thedest
array is not large enough to store all entries ofsrc
list.
-
swap
public static void swap(int[] arr, int i, int j) Swaps to elements in an array. This is done in place.- Parameters:
arr
- Array to swap elements in. This array is modified.i
- Index of first value to swap.j
- Index of second value to swap.- Throws:
IndexOutOfBoundsException
- Ifi
orj
are out of the bounds ofarr
.
-
swap
public static void swap(int[] src, int[] indices) Swaps elements in an array according to a specified permutation.- Parameters:
src
- Array to swap elements within.indices
- Array containing indices of the permutation. If thesrc
array has lengthN
, then the array must be a permutation of{0, 1, 2, ..., N-1}
.- Throws:
IllegalArgumentException
- Ifindices
is not a permutation of{0, 1, 2, ..., N-1}
.
-
swapUnsafe
public static void swapUnsafe(int[] src, int[] indices) Swaps elements in an array according to a specified permutation. This method should be used with extreem caution as unlikeswap(int[], int[])
, this method does not verify thatindices
is a permutation.- Parameters:
src
- Array to swap elements within.indices
- Array containing indices of the permutation. If thesrc
array has lengthN
, then the array must be a permutation of{0, 1, 2, ..., N-1}
.
-
swap
public static void swap(double[] arr, int i, int j) Swaps to elements in an array. This is done in place.- Parameters:
arr
- Array to swap elements in. This array is modified.i
- Index of first value to swap.j
- Index of second value to swap.- Throws:
IndexOutOfBoundsException
- Ifi
orj
are out of the bounds ofarr
.
-
swap
Swaps to elements in an array. This is done in place.- Parameters:
arr
- Array to swap elements in. This array is modified.i
- Index of first value to swap.j
- Index of second value to swap.- Throws:
IndexOutOfBoundsException
- Ifi
orj
are out of the bounds ofarr
.
-
range
public static double[] range(int start, int end) Gets an array filled with integers fromstart
(inclusive) toend
(exclusive)- Parameters:
start
- Staring value (inclusive).end
- Stopping value (exclusive).- Returns:
- An array containing the integer range
[start, end)
.
-
intRange
public static int[] intRange(int start, int end) Gets an array filled with integers fromstart
(inclusive) toend
(exclusive)- Parameters:
start
- Staring value (inclusive).end
- Stopping value (exclusive).- Returns:
- An array containing the integer range
[start, end)
.
-
intRange
public static int[] intRange(int start, int end, int stride) Gets an array filled with integers fromstart
(inclusive) toend
(exclusive) where each int is repeatedstride
times.- Parameters:
start
- Staring value (inclusive).end
- Stopping value (exclusive).stride
- Number of times to repeat each integer.- Returns:
- An array containing the integer range
[start, end)
and each integer is repeatedstride
times. - Throws:
NegativeArraySizeException
- Ifstride
is negative.IllegalArgumentException
- Ifstart
is not in[0, end)
-
equals
Checks if a double array is numerically equal to acomplex number
array.- Parameters:
src1
- Double array.src2
- Complex number array.- Returns:
- True if all entries in
src2
have zero imaginary component and real component equal to the corresponding entry insrc1
. Otherwise, returns false.
-
notContains
public static boolean notContains(int[] src, int key) Checks if a key is in an array.- Parameters:
src
- Source array. Must be sorted, if not, callArrays.sort(double[])
first. Otherwise, the behavior of this method is undefined.key
- Values to check if they are in the source array.- Returns:
- A boolean describing if the specified key is in the array or not.
-
contains
public static boolean[] contains(double[] src, double... keys) Checks if a set of keys are in an array.- Parameters:
src
- Source array. Must be sorted, if not, callArrays.sort(double[])
first. Otherwise, the behavior of this method is undefined.keys
- Values to check if they are in the source array.- Returns:
- A boolean array with the same length as
keys
describing if the associated keys are in the array.
-
contains
public static boolean[] contains(int[] src, int... keys) Checks if a set of keys is in an array.- Parameters:
src
- Source array. Must be sorted, if not, callArrays.sort(int[])
first. Otherwise, the behavior of this method is undefined.keys
- Values to check if they are in the source array.- Returns:
- A boolean array with the same length as
keys
describing if the associated keys are in the array.
-
contains
public static boolean contains(int[] arr, int key) Checks if an array contains a specified value. This method assumes that the array is sorted as it uses the binary search algorithm. If the array is not sorted, useArrays.sort(int[])
first.- Parameters:
arr
- Array of interest.key
- Value to check for in thearr
array.- Returns:
- True if the
key
value is found in the array. False otherwise. - See Also:
-
contains
public static boolean contains(double[] arr, double key) Checks if an array contains a specified value. This method assumes that the array is sorted as it uses the binary search algorithm. If the array is not sorted, useArrays.sort(int[])
first.- Parameters:
arr
- Array of interest.key
- Value to check for in thearr
array.- Returns:
- True if the
key
value is found in the array. False otherwise. - See Also:
-
flatten
public static int[] flatten(int[][] src) Flattens a two-dimensional array.- Parameters:
src
- Array to flatten.- Returns:
- The flattened array.
-
flatten
public static double[] flatten(double[][] src) Flattens a two-dimensional array.- Parameters:
src
- Array to flatten.- Returns:
- The flattened array.
-
unboxFlatten
Flattens a two-dimensional array and unboxes.- Parameters:
src
- Array to flatten and unbox.- Returns:
- The flattened array.
-
flatten
-
join
public static double[] join(double[] src1, double[] src2) Joins two arrays together.- Parameters:
src1
- First array to join.src2
- Second array to join.- Returns:
- A single array of length
src1.length + src2.length
containing the elements ofsrc1
followed by the elements ofsrc2
.
-
join
public static int[] join(int[] src1, int[] src2) Joins two arrays together.- Parameters:
src1
- First array to join.src2
- Second array to join.- Returns:
- A single array of length
src1.length + src2.length
containing the elements ofsrc1
followed by the elements ofsrc2
.
-
notInAxes
public static int[] notInAxes(int[] srcAxes, int dim) Given a list of integers,srcAxes
, which is a subset of{0, 1, 2, ...., dim-1}
in no particular order, compute the integers which are in{0, 1, 2, ...., dim-1}
but not insrcAxes
.- Parameters:
srcAxes
- Source axes which contains a subset of{0, 1, 2, ...., dim-1}
in no particular order.dim
- Dimension of space which contains the axes of interest.- Returns:
- An array containing the set subtraction
{0, 1, 2, ...., dim-1}
- srcAxes.
-
shift
public static int[] shift(int shift, int[] indices) Shifts all indices in an array by a specified amount.- Parameters:
shift
- Amount to shift indices by.indices
- Array of indices to shift.- Returns:
- A reference to
indices
. - See Also:
-
shiftRange
public static int[] shiftRange(int shift, int[] indices, int start, int stop) Shifts a range of indices in an array by a specified amount.- Parameters:
shift
- Amount to shift indices by.indices
- Array of indices to shift.start
- Starting index of range to shift (inclusive).stop
- Stopping index of range to shift (exclusive).- Returns:
- A reference to
indices
. - Throws:
ArrayIndexOutOfBoundsException
- If start or stop is not within the bounds of theindices
array.- See Also:
-
uniqueSorted
public static int[] uniqueSorted(int[] src) Gets the unique values from an array and sorts them.- Parameters:
src
- The array to get unique values from.- Returns:
- A sorted array containing all unique values in the
src
array.
-
indexOf
public static int indexOf(int[] arr, int key) Finds the fist index of the specifiedkey
within an array. If the element does not exist, then-1
is returned.- Parameters:
arr
- Array of interest.key
- Key value to search for.- Returns:
- Returns the first index of the value
key
within thearr
array. If thekey
does not occur in the array,-1
will be returned.
-
unbox
-
unbox
-
boxed
Converts a primitive array to an array of equivalent boxed type.- Parameters:
src
- The source primitive array to box.- Returns:
- A boxed array equivalent to the
src
primitive array.
-
boxed
Converts a primitive array to an array of equivalent boxed type.- Parameters:
src
- The source primitive array to box.- Returns:
- A boxed array equivalent to the
src
primitive array.
-
numUnique
public static int numUnique(double[] arr) Counts the number of unique elements in an array.- Parameters:
arr
- Array to count unique elements in.- Returns:
- The number of unique elements in
arr
.
-
numUnique
public static int numUnique(int[] arr) Counts the number of unique elements in an array.- Parameters:
arr
- Array to count unique elements in.- Returns:
- The number of unique elements in
arr
.
-
createUniqueMapping
Creates a mapping of unique values in {code arr} to integers such that each unique value is mapped to a unique integer and those integers range from0
tonumUnique(arr) - 1
.- Parameters:
arr
- Array to create a mapping for.- Returns:
- A mapping of unique values in {code arr} to integers such that each unique value is
mapped to a unique integer and those integers range from
0
tonumUnique(arr) - 1
.
-
findFirstLast
public static int[] findFirstLast(int[] src, int key) Finds the first and last index of a specified key within a sorted array.- Parameters:
src
- The source array to search within. This array is assumed ot be sorted. If the array is not sorted, callArrays.sort(src)
before this method. If this is not done, and an unsorted array is passed to this method, the results are undefined.key
- The key value to find the first and last index of within thesrc
array.- Returns:
- An array of length 2 containing the first (inclusive) and last (exclusive) index of the
key
within thesrc
array. If thekey
value does not exist in the array, then both first and last index will be(-insertion_point - 1)
whereinsertion_point
is defined as the index thekey
would be inserted into the sorted array.
-
repeat
public static int[] repeat(int numTimes, int[] src) Repeats an array a specified number of times.- Parameters:
numTimes
- Number of times to repeat the array.src
- The source array to repeat.- Returns:
- The
src
array repeatednumTimes times
.
-
filledArray
public static int[] filledArray(int size, int value) Constructs an array filled with a specific value.- Parameters:
size
- Size of the array.value
- Value to set each index of the array.- Returns:
- An array of specified
size
filled with the specifiedvalue
. - Throws:
NegativeArraySizeException
- If is negative.
-
asDouble
public static double[] asDouble(int[] src, double[] dest) Converts an array of ints to an array of doubles.- Parameters:
src
- Source array to convert.dest
- Destination array to store double values equivalent to the values in thesrc
array. If null, a new double array with the same size assrc
will be created.- Returns:
- A reference to the
dest
array.
-
asDouble
Converts an array ofIntegers
to an array of doubles.- Parameters:
src
- Source array to convert.dest
- Destination array to store double values equivalent to the values in thesrc
array. If null, a new double array with the same size assrc
will be created.- Returns:
- A reference to the
dest
array.
-
splice
Splices an array into another array at the specified index.- Parameters:
arr1
- First array.arr2
- Array to splice intoarr1
.spliceIdx
- The index withinarr1
to splicearr2
into.- Returns:
- The result of splicing
arr2
intoarr1
at the indexspliceIdx
.
-
splice
Splices an array into another array at the specified index.- Parameters:
arr1
- First array.arr2
- Array to splice intoarr1
.spliceIdx
- The index withinarr1
to splicearr2
into.- Returns:
- The result of splicing
arr2
intoarr1
at the indexspliceIdx
.
-
splice
Splices an array into another array at the specified index.- Parameters:
arr1
- First array.arr2
- Array to splice intoarr1
.spliceIdx
- The index withinarr1
to splicearr2
into.- Returns:
- The result of splicing
arr2
intoarr1
at the indexspliceIdx
.
-
splice
public static double[] splice(double[] arr1, double[] arr2, int spliceIdx) Splices an array into another array at the specified index.- Parameters:
arr1
- First array.arr2
- Array to splice intoarr1
.spliceIdx
- The index withinarr1
to splicearr2
into.- Returns:
- The result of splicing
arr2
intoarr1
at the indexspliceIdx
.
-
splice
public static int[] splice(int[] arr1, int[] arr2, int spliceIdx) Splices an array into another array at the specified index.- Parameters:
arr1
- First array.arr2
- Array to splice intoarr1
.spliceIdx
- The index withinarr1
to splicearr2
into.- Returns:
- The result of splicing
arr2
intoarr1
at the indexspliceIdx
.
-
splice
Splices an array into a list at the specified index. The list is implicitly converted to an array.- Parameters:
list
- List to splice into.arr
- Array to splice intolist
.spliceIdx
- The index withinlist
to splicearr
into.- Returns:
- The result of splicing
arr
intolist
at the indexspliceIdx
.
-
spliceDouble
Splices an array into a list at the specified index. The list is implicitly converted to an array.- Parameters:
list
- List to splice into.arr
- Array to splice intolist
.spliceIdx
- The index withinlist
to splicearr
into.- Returns:
- The result of splicing
arr
intolist
at the indexspliceIdx
.
-
splice
Splices an array into a list at the specified index. The list is implicitly converted to an array.- Parameters:
list
- List to splice into.arr
- Array to splice intolist
.spliceIdx
- The index withinlist
to splicearr
into.- Returns:
- The result of splicing
arr
intolist
at the indexspliceIdx
.
-
splice
Splices an array into a list at the specified index. The list is implicitly converted to an array.- Parameters:
list
- List to splice into.arr
- Array to splice intolist
.spliceIdx
- The index withinlist
to splicearr
into.- Returns:
- The result of splicing
arr
intolist
at the indexspliceIdx
.
-
applyTransform
Applies a transform to an array. This is done in place.- Parameters:
src
- Array to apply transform to. Modified.opp
- Operation to use to transform the array.- Returns:
- A reference to the
src
array.
-
applyTransform
Applies a transform to an array. This is done in place.- Parameters:
src
- Array to apply transform to. Modified.opp
- Operation to use to transform the array.- Returns:
- A reference to the
src
array.
-
applyTransform
Applies a transform to an array. Note, unlikeapplyTransform(double[], UnaryOperator)
andapplyTransform(Object[], UnaryOperator)
, this method does not work in place.- Parameters:
src
- Array to apply transform to.opp
- Operation to use to transform the array.- Returns:
- A new array containing the result of the transformation.
- See Also:
-
applyTransform
Applies a transform to an array. Note, unlikeapplyTransform(double[], UnaryOperator)
andapplyTransform(Object[], UnaryOperator)
, this method does not work in place.- Parameters:
src
- Array to apply transform to.opp
- Operation to use to transform the array.- Returns:
- A new array containing the result of the transformation.
- See Also:
-