public class BigArrays
extends java.lang.Object
A big array is an array-of-arrays representation of an array. The
length of a big array is bounded by SEGMENT_SIZE
*
Integer.MAX_VALUE
= 134217728 * (231 −
1) rather than Integer.MAX_VALUE
. The type of a big array is that of
an array-of-arrays, so a big array of integers is of type
int[][]
. Note that SEGMENT_SIZE
has been chosen so that
a single segment is smaller than 231 bytes independently of the
data type. It might be enlarged in the future.
If a
is a big array, a[0]
, a[1]
,
… are called the segments of the big array. All segments,
except possibly for the last one, are of length SEGMENT_SIZE
. Given
an index i
into a big array, there is an associated
segment and an associated
displacement into that segment. Access to single members happens by
means of accessors (see, e.g., get(int[][], long)
and
set(int[][], long, int)
), but you can also use the
methods segment(long)
/displacement(long)
to access entries
manually.
The intended usage of most of the methods of this class is that they will be imported statically: for example,
import static it.unimi.dsi.fastutil.BigArrays.copy; import static it.unimi.dsi.fastutil.BigArrays.get; import static it.unimi.dsi.fastutil.BigArrays.length; import static it.unimi.dsi.fastutil.BigArrays.set;
Dynamic binding will take care of selecting the right method depending on the array type.
You can scan a big array using the following idiomatic form:
for(int s = 0; s < a.length; s++) { final int[] t = a[s]; final int l = t.length; for(int d = 0; d < l; d++) { do something with t[d] } }or using the simpler reversed version:
for(int s = a.length; s-- != 0;) { final int[] t = a[s]; for(int d = t.length; d-- != 0;) { do something with t[d] } }
Inside the inner loop, the original index in a
can be retrieved
using index(segment, displacement)
. You can also
use an additional long to keep track of the index.
Note that caching is essential in making these loops essentially as fast as those scanning standard arrays (as iterations of the outer loop happen very rarely). Using loops of this kind is extremely faster than using a standard loop and accessors.
In some situations, you might want to iterate over a part of a big array having an offset and a length. In this case, the idiomatic loops are as follows:
for(int s = segment(offset); s < segment(offset + length + SEGMENT_MASK); s++) { final int[] t = a[s]; final int l = (int)Math.min(t.length, offset + length - start(s)); for(int d = (int)Math.max(0, offset - start(s)); d < l; d++) { do something with t[d] } }or, in a reversed form,
for(int s = segment(offset + length + SEGMENT_MASK); s-- != segment(offset);) { final int[] t = a[s]; final int b = (int)Math.max(0, offset - start(s)); for(int d = (int)Math.min(t.length, offset + length - start(s)); d-- != b ;) { do something with t[d] } }
A literal big array can be easily created by using the suitable type-specific
wrap()
method (e.g., wrap(int[])
) around a
standard Java literal array.
Limited support is available for atomic big arrays of integers and longs, with a similar syntax. Atomic big arrays are
arrays of instances of AtomicIntegerArray
or
AtomicLongArray
of length SEGMENT_SIZE
(or less, for
the last segment, as usual) and their size cannot be changed. Some methods from those classes are
available in BigArrays
for atomic big arrays (e.g.,
incrementAndGet(AtomicIntegerArray[], long)
).
If you find the kind of “bare hands” approach to big arrays not
enough object-oriented, please use big lists based on big arrays (e.g.,
IntBigArrayBigList
). Big arrays follow the Java tradition of
considering arrays as a “legal alien”—something in-between
an object and a primitive type. This approach lacks the consistency of a full
object-oriented approach, but provides some significant performance gains.
In particular, the ensureCapacity()
, grow()
,
trim()
and setLength()
methods allow to handle
arrays much like array lists.
In addition to commodity methods, this class contains BigSwapper
-based
implementations of
quicksort and
of a stable, in-place
mergesort.
These generic sorting methods can be used to sort any kind of list, but they
find their natural usage, for instance, in sorting big arrays in parallel.
Arrays
Modifier and Type | Field and Description |
---|---|
static int |
SEGMENT_MASK
The mask used to compute the displacement associated to an index.
|
static int |
SEGMENT_SHIFT
The shift used to compute the segment associated with an index
(equivalently, the logarithm of the segment size).
|
static int |
SEGMENT_SIZE
The current size of a segment (227) is the largest size that
makes the physical memory allocation for a single segment strictly
smaller than 231 bytes.
|
Modifier and Type | Method and Description |
---|---|
static void |
add(byte[][] array,
long index,
byte incr)
Adds the specified increment the element of the given big array of specified index.
|
static void |
add(char[][] array,
long index,
char incr)
Adds the specified increment the element of the given big array of specified index.
|
static void |
add(double[][] array,
long index,
double incr)
Adds the specified increment the element of the given big array of specified index.
|
static void |
add(float[][] array,
long index,
float incr)
Adds the specified increment the element of the given big array of specified index.
|
static void |
add(int[][] array,
long index,
int incr)
Adds the specified increment the element of the given big array of specified index.
|
static void |
add(long[][] array,
long index,
long incr)
Adds the specified increment the element of the given big array of specified index.
|
static void |
add(short[][] array,
long index,
short incr)
Adds the specified increment the element of the given big array of specified index.
|
static int |
addAndGet(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index,
int value)
Atomically adds a value to an element of the given big atomic array, returning the new value.
|
static long |
addAndGet(java.util.concurrent.atomic.AtomicLongArray[] array,
long index,
long value)
Atomically adds a value to an element of the given big atomic array, returning the new value.
|
static boolean |
compareAndSet(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index,
int expected,
int value)
Atomically sets an element of the given big atomic array of specified index to specified value, given
the current value is equal to a given expected value.
|
static boolean |
compareAndSet(java.util.concurrent.atomic.AtomicLongArray[] array,
long index,
long expected,
long value)
Atomically sets an element of the given big atomic array of specified index to specified value, given
the current value is equal to a given expected value.
|
static boolean[][] |
copy(boolean[][] array)
Returns a copy of a big array.
|
static void |
copy(boolean[][] srcArray,
long srcPos,
boolean[][] destArray,
long destPos,
long length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination big array.
|
static boolean[][] |
copy(boolean[][] array,
long offset,
long length)
Returns a copy of a portion of a big array.
|
static byte[][] |
copy(byte[][] array)
Returns a copy of a big array.
|
static void |
copy(byte[][] srcArray,
long srcPos,
byte[][] destArray,
long destPos,
long length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination big array.
|
static byte[][] |
copy(byte[][] array,
long offset,
long length)
Returns a copy of a portion of a big array.
|
static char[][] |
copy(char[][] array)
Returns a copy of a big array.
|
static void |
copy(char[][] srcArray,
long srcPos,
char[][] destArray,
long destPos,
long length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination big array.
|
static char[][] |
copy(char[][] array,
long offset,
long length)
Returns a copy of a portion of a big array.
|
static double[][] |
copy(double[][] array)
Returns a copy of a big array.
|
static void |
copy(double[][] srcArray,
long srcPos,
double[][] destArray,
long destPos,
long length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination big array.
|
static double[][] |
copy(double[][] array,
long offset,
long length)
Returns a copy of a portion of a big array.
|
static float[][] |
copy(float[][] array)
Returns a copy of a big array.
|
static void |
copy(float[][] srcArray,
long srcPos,
float[][] destArray,
long destPos,
long length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination big array.
|
static float[][] |
copy(float[][] array,
long offset,
long length)
Returns a copy of a portion of a big array.
|
static int[][] |
copy(int[][] array)
Returns a copy of a big array.
|
static void |
copy(int[][] srcArray,
long srcPos,
int[][] destArray,
long destPos,
long length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination big array.
|
static int[][] |
copy(int[][] array,
long offset,
long length)
Returns a copy of a portion of a big array.
|
static <K> K[][] |
copy(K[][] array)
Returns a copy of a big array.
|
static <K> void |
copy(K[][] srcArray,
long srcPos,
K[][] destArray,
long destPos,
long length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination big array.
|
static <K> K[][] |
copy(K[][] array,
long offset,
long length)
Returns a copy of a portion of a big array.
|
static long[][] |
copy(long[][] array)
Returns a copy of a big array.
|
static long[][] |
copy(long[][] array,
long offset,
long length)
Returns a copy of a portion of a big array.
|
static void |
copy(long[][] srcArray,
long srcPos,
long[][] destArray,
long destPos,
long length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination big array.
|
static short[][] |
copy(short[][] array)
Returns a copy of a big array.
|
static short[][] |
copy(short[][] array,
long offset,
long length)
Returns a copy of a portion of a big array.
|
static void |
copy(short[][] srcArray,
long srcPos,
short[][] destArray,
long destPos,
long length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination big array.
|
static void |
copyFromBig(boolean[][] srcArray,
long srcPos,
boolean[] destArray,
int destPos,
int length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination array.
|
static void |
copyFromBig(byte[][] srcArray,
long srcPos,
byte[] destArray,
int destPos,
int length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination array.
|
static void |
copyFromBig(char[][] srcArray,
long srcPos,
char[] destArray,
int destPos,
int length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination array.
|
static void |
copyFromBig(double[][] srcArray,
long srcPos,
double[] destArray,
int destPos,
int length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination array.
|
static void |
copyFromBig(float[][] srcArray,
long srcPos,
float[] destArray,
int destPos,
int length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination array.
|
static void |
copyFromBig(int[][] srcArray,
long srcPos,
int[] destArray,
int destPos,
int length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination array.
|
static <K> void |
copyFromBig(K[][] srcArray,
long srcPos,
K[] destArray,
int destPos,
int length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination array.
|
static void |
copyFromBig(long[][] srcArray,
long srcPos,
long[] destArray,
int destPos,
int length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination array.
|
static void |
copyFromBig(short[][] srcArray,
long srcPos,
short[] destArray,
int destPos,
int length)
Copies a big array from the specified source big array, beginning at the specified position, to the specified position of the destination array.
|
static void |
copyToBig(boolean[] srcArray,
int srcPos,
boolean[][] destArray,
long destPos,
long length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination big array.
|
static void |
copyToBig(byte[] srcArray,
int srcPos,
byte[][] destArray,
long destPos,
long length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination big array.
|
static void |
copyToBig(char[] srcArray,
int srcPos,
char[][] destArray,
long destPos,
long length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination big array.
|
static void |
copyToBig(double[] srcArray,
int srcPos,
double[][] destArray,
long destPos,
long length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination big array.
|
static void |
copyToBig(float[] srcArray,
int srcPos,
float[][] destArray,
long destPos,
long length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination big array.
|
static void |
copyToBig(int[] srcArray,
int srcPos,
int[][] destArray,
long destPos,
long length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination big array.
|
static <K> void |
copyToBig(K[] srcArray,
int srcPos,
K[][] destArray,
long destPos,
long length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination big array.
|
static void |
copyToBig(long[] srcArray,
int srcPos,
long[][] destArray,
long destPos,
long length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination big array.
|
static void |
copyToBig(short[] srcArray,
int srcPos,
short[][] destArray,
long destPos,
long length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination big array.
|
static void |
decr(byte[][] array,
long index)
Decrements the element of the given big array of specified index.
|
static void |
decr(char[][] array,
long index)
Decrements the element of the given big array of specified index.
|
static void |
decr(double[][] array,
long index)
Decrements the element of the given big array of specified index.
|
static void |
decr(float[][] array,
long index)
Decrements the element of the given big array of specified index.
|
static void |
decr(int[][] array,
long index)
Decrements the element of the given big array of specified index.
|
static void |
decr(long[][] array,
long index)
Decrements the element of the given big array of specified index.
|
static void |
decr(short[][] array,
long index)
Decrements the element of the given big array of specified index.
|
static int |
decrementAndGet(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index)
Atomically decrements an element of the given big atomic array, returning the new value.
|
static long |
decrementAndGet(java.util.concurrent.atomic.AtomicLongArray[] array,
long index)
Atomically decrements an element of the given big atomic array, returning the new value.
|
static int |
displacement(long index)
Computes the displacement associated with a given index.
|
static boolean[][] |
ensureCapacity(boolean[][] array,
long length)
Ensures that a big array can contain the given number of entries.
|
static boolean[][] |
ensureCapacity(boolean[][] array,
long length,
long preserve)
Ensures that a big array can contain the given number of entries, preserving just a part of the big array.
|
static byte[][] |
ensureCapacity(byte[][] array,
long length)
Ensures that a big array can contain the given number of entries.
|
static byte[][] |
ensureCapacity(byte[][] array,
long length,
long preserve)
Ensures that a big array can contain the given number of entries, preserving just a part of the big array.
|
static char[][] |
ensureCapacity(char[][] array,
long length)
Ensures that a big array can contain the given number of entries.
|
static char[][] |
ensureCapacity(char[][] array,
long length,
long preserve)
Ensures that a big array can contain the given number of entries, preserving just a part of the big array.
|
static double[][] |
ensureCapacity(double[][] array,
long length)
Ensures that a big array can contain the given number of entries.
|
static double[][] |
ensureCapacity(double[][] array,
long length,
long preserve)
Ensures that a big array can contain the given number of entries, preserving just a part of the big array.
|
static float[][] |
ensureCapacity(float[][] array,
long length)
Ensures that a big array can contain the given number of entries.
|
static float[][] |
ensureCapacity(float[][] array,
long length,
long preserve)
Ensures that a big array can contain the given number of entries, preserving just a part of the big array.
|
static int[][] |
ensureCapacity(int[][] array,
long length)
Ensures that a big array can contain the given number of entries.
|
static int[][] |
ensureCapacity(int[][] array,
long length,
long preserve)
Ensures that a big array can contain the given number of entries, preserving just a part of the big array.
|
static <K> K[][] |
ensureCapacity(K[][] array,
long length)
Ensures that a big array can contain the given number of entries.
|
static <K> K[][] |
ensureCapacity(K[][] array,
long length,
long preserve)
Ensures that a big array can contain the given number of entries, preserving just a part of the big array.
|
static long[][] |
ensureCapacity(long[][] array,
long length)
Ensures that a big array can contain the given number of entries.
|
static long[][] |
ensureCapacity(long[][] array,
long length,
long preserve)
Ensures that a big array can contain the given number of entries, preserving just a part of the big array.
|
static short[][] |
ensureCapacity(short[][] array,
long length)
Ensures that a big array can contain the given number of entries.
|
static short[][] |
ensureCapacity(short[][] array,
long length,
long preserve)
Ensures that a big array can contain the given number of entries, preserving just a part of the big array.
|
static void |
ensureFromTo(boolean[][] a,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big array.
|
static void |
ensureFromTo(byte[][] a,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big array.
|
static void |
ensureFromTo(char[][] a,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big array.
|
static void |
ensureFromTo(double[][] a,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big array.
|
static void |
ensureFromTo(float[][] a,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big array.
|
static void |
ensureFromTo(int[][] a,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big array.
|
static <K> void |
ensureFromTo(K[][] a,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big array.
|
static void |
ensureFromTo(long[][] a,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big array.
|
static void |
ensureFromTo(long bigArrayLength,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive)
elements fits a big array of given length.
|
static void |
ensureFromTo(short[][] a,
long from,
long to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big array.
|
static void |
ensureLength(long bigArrayLength)
Ensures that a big-array length is legal.
|
static void |
ensureOffsetLength(boolean[][] a,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array.
|
static void |
ensureOffsetLength(byte[][] a,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array.
|
static void |
ensureOffsetLength(char[][] a,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array.
|
static void |
ensureOffsetLength(double[][] a,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array.
|
static void |
ensureOffsetLength(float[][] a,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array.
|
static void |
ensureOffsetLength(int[][] a,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array.
|
static <K> void |
ensureOffsetLength(K[][] a,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array.
|
static void |
ensureOffsetLength(long[][] a,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array.
|
static void |
ensureOffsetLength(long bigArrayLength,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array of
given length.
|
static void |
ensureOffsetLength(short[][] a,
long offset,
long length)
Ensures that a range given by an offset and a length fits a big array.
|
static void |
ensureSameLength(boolean[][] a,
boolean[][] b)
Ensures that two big arrays are of the same length.
|
static void |
ensureSameLength(byte[][] a,
byte[][] b)
Ensures that two big arrays are of the same length.
|
static void |
ensureSameLength(char[][] a,
char[][] b)
Ensures that two big arrays are of the same length.
|
static void |
ensureSameLength(double[][] a,
double[][] b)
Ensures that two big arrays are of the same length.
|
static void |
ensureSameLength(float[][] a,
float[][] b)
Ensures that two big arrays are of the same length.
|
static void |
ensureSameLength(int[][] a,
int[][] b)
Ensures that two big arrays are of the same length.
|
static <K> void |
ensureSameLength(K[][] a,
K[][] b)
Ensures that two big arrays are of the same length.
|
static void |
ensureSameLength(long[][] a,
long[][] b)
Ensures that two big arrays are of the same length.
|
static void |
ensureSameLength(short[][] a,
short[][] b)
Ensures that two big arrays are of the same length.
|
static boolean |
equals(boolean[][] a1,
boolean[][] a2)
Returns true if the two big arrays are elementwise equal.
|
static boolean |
equals(byte[][] a1,
byte[][] a2)
Returns true if the two big arrays are elementwise equal.
|
static boolean |
equals(char[][] a1,
char[][] a2)
Returns true if the two big arrays are elementwise equal.
|
static boolean |
equals(double[][] a1,
double[][] a2)
Returns true if the two big arrays are elementwise equal.
|
static boolean |
equals(float[][] a1,
float[][] a2)
Returns true if the two big arrays are elementwise equal.
|
static boolean |
equals(int[][] a1,
int[][] a2)
Returns true if the two big arrays are elementwise equal.
|
static <K> boolean |
equals(K[][] a1,
K[][] a2)
Returns true if the two big arrays are elementwise equal.
|
static boolean |
equals(long[][] a1,
long[][] a2)
Returns true if the two big arrays are elementwise equal.
|
static boolean |
equals(short[][] a1,
short[][] a2)
Returns true if the two big arrays are elementwise equal.
|
static void |
fill(boolean[][] array,
boolean value)
Fills the given big array with the given value.
|
static void |
fill(boolean[][] array,
long from,
long to,
boolean value)
Fills a portion of the given big array with the given value.
|
static void |
fill(byte[][] array,
byte value)
Fills the given big array with the given value.
|
static void |
fill(byte[][] array,
long from,
long to,
byte value)
Fills a portion of the given big array with the given value.
|
static void |
fill(char[][] array,
char value)
Fills the given big array with the given value.
|
static void |
fill(char[][] array,
long from,
long to,
char value)
Fills a portion of the given big array with the given value.
|
static void |
fill(double[][] array,
double value)
Fills the given big array with the given value.
|
static void |
fill(double[][] array,
long from,
long to,
double value)
Fills a portion of the given big array with the given value.
|
static void |
fill(float[][] array,
float value)
Fills the given big array with the given value.
|
static void |
fill(float[][] array,
long from,
long to,
float value)
Fills a portion of the given big array with the given value.
|
static void |
fill(int[][] array,
int value)
Fills the given big array with the given value.
|
static void |
fill(int[][] array,
long from,
long to,
int value)
Fills a portion of the given big array with the given value.
|
static <K> void |
fill(K[][] array,
K value)
Fills the given big array with the given value.
|
static <K> void |
fill(K[][] array,
long from,
long to,
K value)
Fills a portion of the given big array with the given value.
|
static void |
fill(long[][] array,
long value)
Fills the given big array with the given value.
|
static void |
fill(long[][] array,
long from,
long to,
long value)
Fills a portion of the given big array with the given value.
|
static void |
fill(short[][] array,
long from,
long to,
short value)
Fills a portion of the given big array with the given value.
|
static void |
fill(short[][] array,
short value)
Fills the given big array with the given value.
|
static boolean[][] |
forceCapacity(boolean[][] array,
long length,
long preserve)
Forces a big array to contain the given number of entries, preserving just a part of the big array.
|
static byte[][] |
forceCapacity(byte[][] array,
long length,
long preserve)
Forces a big array to contain the given number of entries, preserving just a part of the big array.
|
static char[][] |
forceCapacity(char[][] array,
long length,
long preserve)
Forces a big array to contain the given number of entries, preserving just a part of the big array.
|
static double[][] |
forceCapacity(double[][] array,
long length,
long preserve)
Forces a big array to contain the given number of entries, preserving just a part of the big array.
|
static float[][] |
forceCapacity(float[][] array,
long length,
long preserve)
Forces a big array to contain the given number of entries, preserving just a part of the big array.
|
static int[][] |
forceCapacity(int[][] array,
long length,
long preserve)
Forces a big array to contain the given number of entries, preserving just a part of the big array.
|
static <K> K[][] |
forceCapacity(K[][] array,
long length,
long preserve)
Forces a big array to contain the given number of entries, preserving just a part of the big array.
|
static long[][] |
forceCapacity(long[][] array,
long length,
long preserve)
Forces a big array to contain the given number of entries, preserving just a part of the big array.
|
static short[][] |
forceCapacity(short[][] array,
long length,
long preserve)
Forces a big array to contain the given number of entries, preserving just a part of the big array.
|
static int |
get(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index)
Returns the element of the given big atomic array of specified index.
|
static long |
get(java.util.concurrent.atomic.AtomicLongArray[] array,
long index)
Returns the element of the given big atomic array of specified index.
|
static boolean |
get(boolean[][] array,
long index)
Returns the element of the given big array of specified index.
|
static byte |
get(byte[][] array,
long index)
Returns the element of the given big array of specified index.
|
static char |
get(char[][] array,
long index)
Returns the element of the given big array of specified index.
|
static double |
get(double[][] array,
long index)
Returns the element of the given big array of specified index.
|
static float |
get(float[][] array,
long index)
Returns the element of the given big array of specified index.
|
static int |
get(int[][] array,
long index)
Returns the element of the given big array of specified index.
|
static <K> K |
get(K[][] array,
long index)
Returns the element of the given big array of specified index.
|
static long |
get(long[][] array,
long index)
Returns the element of the given big array of specified index.
|
static short |
get(short[][] array,
long index)
Returns the element of the given big array of specified index.
|
static int |
getAndAdd(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index,
int value)
Atomically adds a value to an element of the given big atomic array, returning the old value.
|
static long |
getAndAdd(java.util.concurrent.atomic.AtomicLongArray[] array,
long index,
long value)
Atomically adds a value to an element of the given big atomic array, returning the old value.
|
static int |
getAndDecrement(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index)
Atomically decrements an element of the given big atomic array, returning the old value.
|
static long |
getAndDecrement(java.util.concurrent.atomic.AtomicLongArray[] array,
long index)
Atomically decrements an element of the given big atomic array, returning the old value.
|
static int |
getAndIncrement(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index)
Atomically increments an element of the given big atomic array, returning the old value.
|
static long |
getAndIncrement(java.util.concurrent.atomic.AtomicLongArray[] array,
long index)
Atomically increments an element of the given big atomic array, returning the old value.
|
static int |
getAndSet(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index,
int value)
Atomically sets an element of the given big atomic array to a specified value, returning the old value.
|
static long |
getAndSet(java.util.concurrent.atomic.AtomicLongArray[] array,
long index,
long value)
Atomically sets an element of the given big atomic array to a specified value, returning the old value.
|
static boolean[][] |
grow(boolean[][] array,
long length)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length.
|
static boolean[][] |
grow(boolean[][] array,
long length,
long preserve)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length, preserving just a part of the big array.
|
static byte[][] |
grow(byte[][] array,
long length)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length.
|
static byte[][] |
grow(byte[][] array,
long length,
long preserve)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length, preserving just a part of the big array.
|
static char[][] |
grow(char[][] array,
long length)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length.
|
static char[][] |
grow(char[][] array,
long length,
long preserve)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length, preserving just a part of the big array.
|
static double[][] |
grow(double[][] array,
long length)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length.
|
static double[][] |
grow(double[][] array,
long length,
long preserve)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length, preserving just a part of the big array.
|
static float[][] |
grow(float[][] array,
long length)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length.
|
static float[][] |
grow(float[][] array,
long length,
long preserve)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length, preserving just a part of the big array.
|
static int[][] |
grow(int[][] array,
long length)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length.
|
static int[][] |
grow(int[][] array,
long length,
long preserve)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length, preserving just a part of the big array.
|
static <K> K[][] |
grow(K[][] array,
long length)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length.
|
static <K> K[][] |
grow(K[][] array,
long length,
long preserve)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length, preserving just a part of the big array.
|
static long[][] |
grow(long[][] array,
long length)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length.
|
static long[][] |
grow(long[][] array,
long length,
long preserve)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length, preserving just a part of the big array.
|
static short[][] |
grow(short[][] array,
long length)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length.
|
static short[][] |
grow(short[][] array,
long length,
long preserve)
Grows the given big array to the maximum between the given length and
the current length increased by 50%, provided that the given
length is larger than the current length, preserving just a part of the big array.
|
static void |
incr(byte[][] array,
long index)
Increments the element of the given big array of specified index.
|
static void |
incr(char[][] array,
long index)
Increments the element of the given big array of specified index.
|
static void |
incr(double[][] array,
long index)
Increments the element of the given big array of specified index.
|
static void |
incr(float[][] array,
long index)
Increments the element of the given big array of specified index.
|
static void |
incr(int[][] array,
long index)
Increments the element of the given big array of specified index.
|
static void |
incr(long[][] array,
long index)
Increments the element of the given big array of specified index.
|
static void |
incr(short[][] array,
long index)
Increments the element of the given big array of specified index.
|
static int |
incrementAndGet(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index)
Atomically increments an element of the given big atomic array, returning the new value.
|
static long |
incrementAndGet(java.util.concurrent.atomic.AtomicLongArray[] array,
long index)
Atomically increments an element of the given big atomic array, returning the new value.
|
static long |
index(int segment,
int displacement)
Computes the index associated with given segment and displacement.
|
static long |
length(java.util.concurrent.atomic.AtomicIntegerArray[] array)
Returns the length of the given big atomic array.
|
static long |
length(java.util.concurrent.atomic.AtomicLongArray[] array)
Returns the length of the given big atomic array.
|
static long |
length(boolean[][] array)
Returns the length of the given big array.
|
static long |
length(byte[][] array)
Returns the length of the given big array.
|
static long |
length(char[][] array)
Returns the length of the given big array.
|
static long |
length(double[][] array)
Returns the length of the given big array.
|
static long |
length(float[][] array)
Returns the length of the given big array.
|
static long |
length(int[][] array)
Returns the length of the given big array.
|
static <K> long |
length(K[][] array)
Returns the length of the given big array.
|
static long |
length(long[][] array)
Returns the length of the given big array.
|
static long |
length(short[][] array)
Returns the length of the given big array.
|
static void |
main(java.lang.String[] arg) |
static void |
mergeSort(long from,
long to,
LongComparator comp,
BigSwapper swapper)
Sorts the specified range of elements using the specified big swapper and
according to the order induced by the specified comparator using
mergesort.
|
static void |
mul(byte[][] array,
long index,
byte factor)
Multiplies by the specified factor the element of the given big array of specified index.
|
static void |
mul(char[][] array,
long index,
char factor)
Multiplies by the specified factor the element of the given big array of specified index.
|
static void |
mul(double[][] array,
long index,
double factor)
Multiplies by the specified factor the element of the given big array of specified index.
|
static void |
mul(float[][] array,
long index,
float factor)
Multiplies by the specified factor the element of the given big array of specified index.
|
static void |
mul(int[][] array,
long index,
int factor)
Multiplies by the specified factor the element of the given big array of specified index.
|
static void |
mul(long[][] array,
long index,
long factor)
Multiplies by the specified factor the element of the given big array of specified index.
|
static void |
mul(short[][] array,
long index,
short factor)
Multiplies by the specified factor the element of the given big array of specified index.
|
static long |
nearestSegmentStart(long index,
long min,
long max)
Computes the nearest segment starting index of a given index.
|
static void |
quickSort(long from,
long to,
LongComparator comp,
BigSwapper swapper)
Sorts the specified range of elements using the specified big swapper and
according to the order induced by the specified comparator using
quicksort.
|
static boolean[][] |
reverse(boolean[][] a)
Reverses the order of the elements in the specified big array.
|
static byte[][] |
reverse(byte[][] a)
Reverses the order of the elements in the specified big array.
|
static char[][] |
reverse(char[][] a)
Reverses the order of the elements in the specified big array.
|
static double[][] |
reverse(double[][] a)
Reverses the order of the elements in the specified big array.
|
static float[][] |
reverse(float[][] a)
Reverses the order of the elements in the specified big array.
|
static int[][] |
reverse(int[][] a)
Reverses the order of the elements in the specified big array.
|
static <K> K[][] |
reverse(K[][] a)
Reverses the order of the elements in the specified big array.
|
static long[][] |
reverse(long[][] a)
Reverses the order of the elements in the specified big array.
|
static short[][] |
reverse(short[][] a)
Reverses the order of the elements in the specified big array.
|
static int |
segment(long index)
Computes the segment associated with a given index.
|
static void |
set(java.util.concurrent.atomic.AtomicIntegerArray[] array,
long index,
int value)
Sets an element of the given big atomic array to a specified value
|
static void |
set(java.util.concurrent.atomic.AtomicLongArray[] array,
long index,
long value)
Sets an element of the given big atomic array to a specified value
|
static void |
set(boolean[][] array,
long index,
boolean value)
Sets the element of the given big array of specified index.
|
static void |
set(byte[][] array,
long index,
byte value)
Sets the element of the given big array of specified index.
|
static void |
set(char[][] array,
long index,
char value)
Sets the element of the given big array of specified index.
|
static void |
set(double[][] array,
long index,
double value)
Sets the element of the given big array of specified index.
|
static void |
set(float[][] array,
long index,
float value)
Sets the element of the given big array of specified index.
|
static void |
set(int[][] array,
long index,
int value)
Sets the element of the given big array of specified index.
|
static <K> void |
set(K[][] array,
long index,
K value)
Sets the element of the given big array of specified index.
|
static void |
set(long[][] array,
long index,
long value)
Sets the element of the given big array of specified index.
|
static void |
set(short[][] array,
long index,
short value)
Sets the element of the given big array of specified index.
|
static boolean[][] |
setLength(boolean[][] array,
long length)
Sets the length of the given big array.
|
static byte[][] |
setLength(byte[][] array,
long length)
Sets the length of the given big array.
|
static char[][] |
setLength(char[][] array,
long length)
Sets the length of the given big array.
|
static double[][] |
setLength(double[][] array,
long length)
Sets the length of the given big array.
|
static float[][] |
setLength(float[][] array,
long length)
Sets the length of the given big array.
|
static int[][] |
setLength(int[][] array,
long length)
Sets the length of the given big array.
|
static <K> K[][] |
setLength(K[][] array,
long length)
Sets the length of the given big array.
|
static long[][] |
setLength(long[][] array,
long length)
Sets the length of the given big array.
|
static short[][] |
setLength(short[][] array,
long length)
Sets the length of the given big array.
|
static boolean[][] |
shuffle(boolean[][] a,
long from,
long to,
java.util.Random random)
Shuffles the specified big array fragment using the specified pseudorandom number generator.
|
static boolean[][] |
shuffle(boolean[][] a,
java.util.Random random)
Shuffles the specified big array using the specified pseudorandom number generator.
|
static byte[][] |
shuffle(byte[][] a,
long from,
long to,
java.util.Random random)
Shuffles the specified big array fragment using the specified pseudorandom number generator.
|
static byte[][] |
shuffle(byte[][] a,
java.util.Random random)
Shuffles the specified big array using the specified pseudorandom number generator.
|
static char[][] |
shuffle(char[][] a,
long from,
long to,
java.util.Random random)
Shuffles the specified big array fragment using the specified pseudorandom number generator.
|
static char[][] |
shuffle(char[][] a,
java.util.Random random)
Shuffles the specified big array using the specified pseudorandom number generator.
|
static double[][] |
shuffle(double[][] a,
long from,
long to,
java.util.Random random)
Shuffles the specified big array fragment using the specified pseudorandom number generator.
|
static double[][] |
shuffle(double[][] a,
java.util.Random random)
Shuffles the specified big array using the specified pseudorandom number generator.
|
static float[][] |
shuffle(float[][] a,
long from,
long to,
java.util.Random random)
Shuffles the specified big array fragment using the specified pseudorandom number generator.
|
static float[][] |
shuffle(float[][] a,
java.util.Random random)
Shuffles the specified big array using the specified pseudorandom number generator.
|
static int[][] |
shuffle(int[][] a,
long from,
long to,
java.util.Random random)
Shuffles the specified big array fragment using the specified pseudorandom number generator.
|
static int[][] |
shuffle(int[][] a,
java.util.Random random)
Shuffles the specified big array using the specified pseudorandom number generator.
|
static <K> K[][] |
shuffle(K[][] a,
long from,
long to,
java.util.Random random)
Shuffles the specified big array fragment using the specified pseudorandom number generator.
|
static <K> K[][] |
shuffle(K[][] a,
java.util.Random random)
Shuffles the specified big array using the specified pseudorandom number generator.
|
static long[][] |
shuffle(long[][] a,
long from,
long to,
java.util.Random random)
Shuffles the specified big array fragment using the specified pseudorandom number generator.
|
static long[][] |
shuffle(long[][] a,
java.util.Random random)
Shuffles the specified big array using the specified pseudorandom number generator.
|
static short[][] |
shuffle(short[][] a,
long from,
long to,
java.util.Random random)
Shuffles the specified big array fragment using the specified pseudorandom number generator.
|
static short[][] |
shuffle(short[][] a,
java.util.Random random)
Shuffles the specified big array using the specified pseudorandom number generator.
|
static long |
start(int segment)
Computes the starting index of a given segment.
|
static void |
swap(boolean[][] array,
long first,
long second)
Swaps the element of the given big array of specified indices.
|
static void |
swap(byte[][] array,
long first,
long second)
Swaps the element of the given big array of specified indices.
|
static void |
swap(char[][] array,
long first,
long second)
Swaps the element of the given big array of specified indices.
|
static void |
swap(double[][] array,
long first,
long second)
Swaps the element of the given big array of specified indices.
|
static void |
swap(float[][] array,
long first,
long second)
Swaps the element of the given big array of specified indices.
|
static void |
swap(int[][] array,
long first,
long second)
Swaps the element of the given big array of specified indices.
|
static <K> void |
swap(K[][] array,
long first,
long second)
Swaps the element of the given big array of specified indices.
|
static void |
swap(long[][] array,
long first,
long second)
Swaps the element of the given big array of specified indices.
|
static void |
swap(short[][] array,
long first,
long second)
Swaps the element of the given big array of specified indices.
|
static java.lang.String |
toString(boolean[][] a) |
static java.lang.String |
toString(byte[][] a) |
static java.lang.String |
toString(char[][] a) |
static java.lang.String |
toString(double[][] a) |
static java.lang.String |
toString(float[][] a) |
static java.lang.String |
toString(int[][] a) |
static <K> java.lang.String |
toString(K[][] a) |
static java.lang.String |
toString(long[][] a) |
static java.lang.String |
toString(short[][] a) |
static boolean[][] |
trim(boolean[][] array,
long length)
Trims the given big array to the given length.
|
static byte[][] |
trim(byte[][] array,
long length)
Trims the given big array to the given length.
|
static char[][] |
trim(char[][] array,
long length)
Trims the given big array to the given length.
|
static double[][] |
trim(double[][] array,
long length)
Trims the given big array to the given length.
|
static float[][] |
trim(float[][] array,
long length)
Trims the given big array to the given length.
|
static int[][] |
trim(int[][] array,
long length)
Trims the given big array to the given length.
|
static <K> K[][] |
trim(K[][] array,
long length)
Trims the given big array to the given length.
|
static long[][] |
trim(long[][] array,
long length)
Trims the given big array to the given length.
|
static short[][] |
trim(short[][] array,
long length)
Trims the given big array to the given length.
|
static boolean[][] |
wrap(boolean[] array)
Turns a standard array into a big array.
|
static byte[][] |
wrap(byte[] array)
Turns a standard array into a big array.
|
static char[][] |
wrap(char[] array)
Turns a standard array into a big array.
|
static double[][] |
wrap(double[] array)
Turns a standard array into a big array.
|
static float[][] |
wrap(float[] array)
Turns a standard array into a big array.
|
static int[][] |
wrap(int[] array)
Turns a standard array into a big array.
|
static <K> K[][] |
wrap(K[] array)
Turns a standard array into a big array.
|
static long[][] |
wrap(long[] array)
Turns a standard array into a big array.
|
static short[][] |
wrap(short[] array)
Turns a standard array into a big array.
|
public static final int SEGMENT_SHIFT
public static final int SEGMENT_SIZE
public static final int SEGMENT_MASK
public static int segment(long index)
index
- an index into a big array.public static int displacement(long index)
index
- an index into a big array.public static long start(int segment)
segment
- the segment of a big array.public static long nearestSegmentStart(long index, long min, long max)
This will either be start(segment(index)
or start(segment(index) + 1)
,
whichever is closer, given the bounds can be respected. If neither segment start is within
the bounds, then the index is returned unmodified.
This method can be useful for operations that seek to align on the outer array's boundaries when possible.
index
- an index into a big array.min
- the minimum (inclusive) valid index of the big array in questionmax
- the maximum (exclusive) valid index of the big array in questionindex
public static long index(int segment, int displacement)
segment
- the segment of a big array.displacement
- the displacement into the segment.segment(index(segment, displacement)) == segment
and
displacement(index(segment,
displacement)) == displacement
.public static void ensureFromTo(long bigArrayLength, long from, long to)
This method may be used whenever a big array range check is needed.
bigArrayLength
- a big-array length.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than
bigArrayLength
or negative.public static void ensureOffsetLength(long bigArrayLength, long offset, long length)
This method may be used whenever a big array range check is needed.
bigArrayLength
- a big-array length.offset
- a start index for the fragmentlength
- a length (the number of elements in the fragment).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+
length
is greater than
bigArrayLength
.public static void ensureLength(long bigArrayLength)
bigArrayLength
- a big-array length.java.lang.IllegalArgumentException
- if length
is negative, or larger than or equal
to SEGMENT_SIZE
* Integer.MAX_VALUE
.public static void mergeSort(long from, long to, LongComparator comp, BigSwapper swapper)
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. The sorting algorithm is an in-place mergesort that is significantly slower than a standard mergesort, as its running time is O(n (log n)2), but it does not allocate additional memory; as a result, it can be used as a generic sorting algorithm.
from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (exclusive) to be sorted.comp
- the comparator to determine the order of the generic data
(arguments are positions).swapper
- an object that knows how to swap the elements at any two
positions.public static void quickSort(long from, long to, LongComparator comp, BigSwapper swapper)
The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.
from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (exclusive) to be sorted.comp
- the comparator to determine the order of the generic data.swapper
- an object that knows how to swap the elements at any two
positions.public static byte get(byte[][] array, long index)
array
- a big array.index
- a position in the big array.public static void set(byte[][] array, long index, byte value)
array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.public static void swap(byte[][] array, long first, long second)
array
- a big array.first
- a position in the big array.second
- a position in the big array.public static byte[][] reverse(byte[][] a)
a
- the big array to be reversed.a
.public static void add(byte[][] array, long index, byte incr)
array
- a big array.index
- a position in the big array.incr
- the incrementpublic static void mul(byte[][] array, long index, byte factor)
array
- a big array.index
- a position in the big array.factor
- the factorpublic static void incr(byte[][] array, long index)
array
- a big array.index
- a position in the big array.public static void decr(byte[][] array, long index)
array
- a big array.index
- a position in the big array.public static long length(byte[][] array)
array
- a big array.public static void copy(byte[][] srcArray, long srcPos, byte[][] destArray, long destPos, long length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyFromBig(byte[][] srcArray, long srcPos, byte[] destArray, int destPos, int length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyToBig(byte[] srcArray, int srcPos, byte[][] destArray, long destPos, long length)
srcArray
- the source array.srcPos
- the starting position in the source array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static byte[][] wrap(byte[] array)
Note that the returned big array might contain as a segment the original array.
array
- an array.array
.public static byte[][] ensureCapacity(byte[][] array, long length)
If you cannot foresee whether this big array will need again to be
enlarged, you should probably use grow()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it contains length
entries or more; otherwise,
a big array with length
entries whose first length(array)
entries are the same as those of array
.public static byte[][] forceCapacity(byte[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.length
entries whose first preserve
entries are the same as those of array
.public static byte[][] ensureCapacity(byte[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries or more; otherwise,
a big array with length
entries whose first preserve
entries are the same as those of array
.public static byte[][] grow(byte[][] array, long length)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
length(array)
entries are the same as those of array
.public static byte[][] grow(byte[][] array, long length, long preserve)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
preserve
entries are the same as those of array
.public static byte[][] trim(byte[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new maximum length for the big array.array
, if it contains length
entries or less; otherwise, a big array with
length
entries whose entries are the same as
the first length
entries of array
.public static byte[][] setLength(byte[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new length for the big array.array
, if it contains exactly length
entries; otherwise, if it contains more than
length
entries, a big array with length
entries
whose entries are the same as the first length
entries of
array
; otherwise, a big array with length
entries
whose first length(array)
entries are the same as those of
array
.public static byte[][] copy(byte[][] array, long offset, long length)
array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.public static byte[][] copy(byte[][] array)
array
- a big array.array
.public static void fill(byte[][] array, byte value)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
array
- a big array.value
- the new value for all elements of the big array.public static void fill(byte[][] array, long from, long to, byte value)
If possible (i.e., from
is 0) this method uses a
backward loop. In this case, it is significantly faster than the
corresponding method in Arrays
.
array
- a big array.from
- the starting index of the portion to fill.to
- the end index of the portion to fill.value
- the new value for all elements of the specified portion of the big array.public static boolean equals(byte[][] a1, byte[][] a2)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.public static java.lang.String toString(byte[][] a)
public static void ensureFromTo(byte[][] a, long from, long to)
This method may be used whenever a big array range check is needed.
a
- a big array.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than the big array length or negative.public static void ensureOffsetLength(byte[][] a, long offset, long length)
This method may be used whenever a big array range check is needed.
a
- a big array.offset
- a start index.length
- a length (the number of elements in the range).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+length
is greater than the big array length.public static void ensureSameLength(byte[][] a, byte[][] b)
a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static byte[][] shuffle(byte[][] a, long from, long to, java.util.Random random)
a
- the big array to be shuffled.from
- the index of the first element (inclusive) to be shuffled.to
- the index of the last element (exclusive) to be shuffled.random
- a pseudorandom number generator.a
.public static byte[][] shuffle(byte[][] a, java.util.Random random)
a
- the big array to be shuffled.random
- a pseudorandom number generator.a
.public static int get(int[][] array, long index)
array
- a big array.index
- a position in the big array.public static void set(int[][] array, long index, int value)
array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.public static long length(java.util.concurrent.atomic.AtomicIntegerArray[] array)
array
- a big atomic array.public static int get(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static void set(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index, int value)
array
- a big atomic array.index
- a position in the big atomic array.value
- a new value for the element of the big atomic array at the specified position.public static int getAndSet(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index, int value)
array
- a big atomic array.index
- a position in the big atomic array.value
- a new value for the element of the big atomic array at the specified position.public static int getAndAdd(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index, int value)
array
- a big atomic array.index
- a position in the big atomic array.value
- a value to add to the element of the big atomic array at the specified position.public static int addAndGet(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index, int value)
array
- a big atomic array.index
- a position in the big atomic array.value
- a value to add to the element of the big atomic array at the specified position.public static int getAndIncrement(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static int incrementAndGet(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static int getAndDecrement(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static int decrementAndGet(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static boolean compareAndSet(java.util.concurrent.atomic.AtomicIntegerArray[] array, long index, int expected, int value)
array
- a big atomic array.index
- a position in the big atomic array.expected
- an expected value for the element of the big atomic array at the specified position.value
- a new value for the element of the big atomic array at the specified position.public static void swap(int[][] array, long first, long second)
array
- a big array.first
- a position in the big array.second
- a position in the big array.public static int[][] reverse(int[][] a)
a
- the big array to be reversed.a
.public static void add(int[][] array, long index, int incr)
array
- a big array.index
- a position in the big array.incr
- the incrementpublic static void mul(int[][] array, long index, int factor)
array
- a big array.index
- a position in the big array.factor
- the factorpublic static void incr(int[][] array, long index)
array
- a big array.index
- a position in the big array.public static void decr(int[][] array, long index)
array
- a big array.index
- a position in the big array.public static long length(int[][] array)
array
- a big array.public static void copy(int[][] srcArray, long srcPos, int[][] destArray, long destPos, long length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyFromBig(int[][] srcArray, long srcPos, int[] destArray, int destPos, int length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyToBig(int[] srcArray, int srcPos, int[][] destArray, long destPos, long length)
srcArray
- the source array.srcPos
- the starting position in the source array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static int[][] wrap(int[] array)
Note that the returned big array might contain as a segment the original array.
array
- an array.array
.public static int[][] ensureCapacity(int[][] array, long length)
If you cannot foresee whether this big array will need again to be
enlarged, you should probably use grow()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it contains length
entries or more; otherwise,
a big array with length
entries whose first length(array)
entries are the same as those of array
.public static int[][] forceCapacity(int[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.length
entries whose first preserve
entries are the same as those of array
.public static int[][] ensureCapacity(int[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries or more; otherwise,
a big array with length
entries whose first preserve
entries are the same as those of array
.public static int[][] grow(int[][] array, long length)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
length(array)
entries are the same as those of array
.public static int[][] grow(int[][] array, long length, long preserve)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
preserve
entries are the same as those of array
.public static int[][] trim(int[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new maximum length for the big array.array
, if it contains length
entries or less; otherwise, a big array with
length
entries whose entries are the same as
the first length
entries of array
.public static int[][] setLength(int[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new length for the big array.array
, if it contains exactly length
entries; otherwise, if it contains more than
length
entries, a big array with length
entries
whose entries are the same as the first length
entries of
array
; otherwise, a big array with length
entries
whose first length(array)
entries are the same as those of
array
.public static int[][] copy(int[][] array, long offset, long length)
array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.public static int[][] copy(int[][] array)
array
- a big array.array
.public static void fill(int[][] array, int value)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
array
- a big array.value
- the new value for all elements of the big array.public static void fill(int[][] array, long from, long to, int value)
If possible (i.e., from
is 0) this method uses a
backward loop. In this case, it is significantly faster than the
corresponding method in Arrays
.
array
- a big array.from
- the starting index of the portion to fill.to
- the end index of the portion to fill.value
- the new value for all elements of the specified portion of the big array.public static boolean equals(int[][] a1, int[][] a2)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.public static java.lang.String toString(int[][] a)
public static void ensureFromTo(int[][] a, long from, long to)
This method may be used whenever a big array range check is needed.
a
- a big array.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than the big array length or negative.public static void ensureOffsetLength(int[][] a, long offset, long length)
This method may be used whenever a big array range check is needed.
a
- a big array.offset
- a start index.length
- a length (the number of elements in the range).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+length
is greater than the big array length.public static void ensureSameLength(int[][] a, int[][] b)
a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static int[][] shuffle(int[][] a, long from, long to, java.util.Random random)
a
- the big array to be shuffled.from
- the index of the first element (inclusive) to be shuffled.to
- the index of the last element (exclusive) to be shuffled.random
- a pseudorandom number generator.a
.public static int[][] shuffle(int[][] a, java.util.Random random)
a
- the big array to be shuffled.random
- a pseudorandom number generator.a
.public static long get(long[][] array, long index)
array
- a big array.index
- a position in the big array.public static void set(long[][] array, long index, long value)
array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.public static long length(java.util.concurrent.atomic.AtomicLongArray[] array)
array
- a big atomic array.public static long get(java.util.concurrent.atomic.AtomicLongArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static void set(java.util.concurrent.atomic.AtomicLongArray[] array, long index, long value)
array
- a big atomic array.index
- a position in the big atomic array.value
- a new value for the element of the big atomic array at the specified position.public static long getAndSet(java.util.concurrent.atomic.AtomicLongArray[] array, long index, long value)
array
- a big atomic array.index
- a position in the big atomic array.value
- a new value for the element of the big atomic array at the specified position.public static long getAndAdd(java.util.concurrent.atomic.AtomicLongArray[] array, long index, long value)
array
- a big atomic array.index
- a position in the big atomic array.value
- a value to add to the element of the big atomic array at the specified position.public static long addAndGet(java.util.concurrent.atomic.AtomicLongArray[] array, long index, long value)
array
- a big atomic array.index
- a position in the big atomic array.value
- a value to add to the element of the big atomic array at the specified position.public static long getAndIncrement(java.util.concurrent.atomic.AtomicLongArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static long incrementAndGet(java.util.concurrent.atomic.AtomicLongArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static long getAndDecrement(java.util.concurrent.atomic.AtomicLongArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static long decrementAndGet(java.util.concurrent.atomic.AtomicLongArray[] array, long index)
array
- a big atomic array.index
- a position in the big atomic array.public static boolean compareAndSet(java.util.concurrent.atomic.AtomicLongArray[] array, long index, long expected, long value)
array
- a big atomic array.index
- a position in the big atomic array.expected
- an expected value for the element of the big atomic array at the specified position.value
- a new value for the element of the big atomic array at the specified position.public static void swap(long[][] array, long first, long second)
array
- a big array.first
- a position in the big array.second
- a position in the big array.public static long[][] reverse(long[][] a)
a
- the big array to be reversed.a
.public static void add(long[][] array, long index, long incr)
array
- a big array.index
- a position in the big array.incr
- the incrementpublic static void mul(long[][] array, long index, long factor)
array
- a big array.index
- a position in the big array.factor
- the factorpublic static void incr(long[][] array, long index)
array
- a big array.index
- a position in the big array.public static void decr(long[][] array, long index)
array
- a big array.index
- a position in the big array.public static long length(long[][] array)
array
- a big array.public static void copy(long[][] srcArray, long srcPos, long[][] destArray, long destPos, long length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyFromBig(long[][] srcArray, long srcPos, long[] destArray, int destPos, int length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyToBig(long[] srcArray, int srcPos, long[][] destArray, long destPos, long length)
srcArray
- the source array.srcPos
- the starting position in the source array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static long[][] wrap(long[] array)
Note that the returned big array might contain as a segment the original array.
array
- an array.array
.public static long[][] ensureCapacity(long[][] array, long length)
If you cannot foresee whether this big array will need again to be
enlarged, you should probably use grow()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it contains length
entries or more; otherwise,
a big array with length
entries whose first length(array)
entries are the same as those of array
.public static long[][] forceCapacity(long[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.length
entries whose first preserve
entries are the same as those of array
.public static long[][] ensureCapacity(long[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries or more; otherwise,
a big array with length
entries whose first preserve
entries are the same as those of array
.public static long[][] grow(long[][] array, long length)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
length(array)
entries are the same as those of array
.public static long[][] grow(long[][] array, long length, long preserve)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
preserve
entries are the same as those of array
.public static long[][] trim(long[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new maximum length for the big array.array
, if it contains length
entries or less; otherwise, a big array with
length
entries whose entries are the same as
the first length
entries of array
.public static long[][] setLength(long[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new length for the big array.array
, if it contains exactly length
entries; otherwise, if it contains more than
length
entries, a big array with length
entries
whose entries are the same as the first length
entries of
array
; otherwise, a big array with length
entries
whose first length(array)
entries are the same as those of
array
.public static long[][] copy(long[][] array, long offset, long length)
array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.public static long[][] copy(long[][] array)
array
- a big array.array
.public static void fill(long[][] array, long value)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
array
- a big array.value
- the new value for all elements of the big array.public static void fill(long[][] array, long from, long to, long value)
If possible (i.e., from
is 0) this method uses a
backward loop. In this case, it is significantly faster than the
corresponding method in Arrays
.
array
- a big array.from
- the starting index of the portion to fill.to
- the end index of the portion to fill.value
- the new value for all elements of the specified portion of the big array.public static boolean equals(long[][] a1, long[][] a2)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.public static java.lang.String toString(long[][] a)
public static void ensureFromTo(long[][] a, long from, long to)
This method may be used whenever a big array range check is needed.
a
- a big array.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than the big array length or negative.public static void ensureOffsetLength(long[][] a, long offset, long length)
This method may be used whenever a big array range check is needed.
a
- a big array.offset
- a start index.length
- a length (the number of elements in the range).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+length
is greater than the big array length.public static void ensureSameLength(long[][] a, long[][] b)
a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static long[][] shuffle(long[][] a, long from, long to, java.util.Random random)
a
- the big array to be shuffled.from
- the index of the first element (inclusive) to be shuffled.to
- the index of the last element (exclusive) to be shuffled.random
- a pseudorandom number generator.a
.public static long[][] shuffle(long[][] a, java.util.Random random)
a
- the big array to be shuffled.random
- a pseudorandom number generator.a
.public static double get(double[][] array, long index)
array
- a big array.index
- a position in the big array.public static void set(double[][] array, long index, double value)
array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.public static void swap(double[][] array, long first, long second)
array
- a big array.first
- a position in the big array.second
- a position in the big array.public static double[][] reverse(double[][] a)
a
- the big array to be reversed.a
.public static void add(double[][] array, long index, double incr)
array
- a big array.index
- a position in the big array.incr
- the incrementpublic static void mul(double[][] array, long index, double factor)
array
- a big array.index
- a position in the big array.factor
- the factorpublic static void incr(double[][] array, long index)
array
- a big array.index
- a position in the big array.public static void decr(double[][] array, long index)
array
- a big array.index
- a position in the big array.public static long length(double[][] array)
array
- a big array.public static void copy(double[][] srcArray, long srcPos, double[][] destArray, long destPos, long length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyFromBig(double[][] srcArray, long srcPos, double[] destArray, int destPos, int length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyToBig(double[] srcArray, int srcPos, double[][] destArray, long destPos, long length)
srcArray
- the source array.srcPos
- the starting position in the source array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static double[][] wrap(double[] array)
Note that the returned big array might contain as a segment the original array.
array
- an array.array
.public static double[][] ensureCapacity(double[][] array, long length)
If you cannot foresee whether this big array will need again to be
enlarged, you should probably use grow()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it contains length
entries or more; otherwise,
a big array with length
entries whose first length(array)
entries are the same as those of array
.public static double[][] forceCapacity(double[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.length
entries whose first preserve
entries are the same as those of array
.public static double[][] ensureCapacity(double[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries or more; otherwise,
a big array with length
entries whose first preserve
entries are the same as those of array
.public static double[][] grow(double[][] array, long length)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
length(array)
entries are the same as those of array
.public static double[][] grow(double[][] array, long length, long preserve)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
preserve
entries are the same as those of array
.public static double[][] trim(double[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new maximum length for the big array.array
, if it contains length
entries or less; otherwise, a big array with
length
entries whose entries are the same as
the first length
entries of array
.public static double[][] setLength(double[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new length for the big array.array
, if it contains exactly length
entries; otherwise, if it contains more than
length
entries, a big array with length
entries
whose entries are the same as the first length
entries of
array
; otherwise, a big array with length
entries
whose first length(array)
entries are the same as those of
array
.public static double[][] copy(double[][] array, long offset, long length)
array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.public static double[][] copy(double[][] array)
array
- a big array.array
.public static void fill(double[][] array, double value)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
array
- a big array.value
- the new value for all elements of the big array.public static void fill(double[][] array, long from, long to, double value)
If possible (i.e., from
is 0) this method uses a
backward loop. In this case, it is significantly faster than the
corresponding method in Arrays
.
array
- a big array.from
- the starting index of the portion to fill.to
- the end index of the portion to fill.value
- the new value for all elements of the specified portion of the big array.public static boolean equals(double[][] a1, double[][] a2)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.public static java.lang.String toString(double[][] a)
public static void ensureFromTo(double[][] a, long from, long to)
This method may be used whenever a big array range check is needed.
a
- a big array.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than the big array length or negative.public static void ensureOffsetLength(double[][] a, long offset, long length)
This method may be used whenever a big array range check is needed.
a
- a big array.offset
- a start index.length
- a length (the number of elements in the range).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+length
is greater than the big array length.public static void ensureSameLength(double[][] a, double[][] b)
a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static double[][] shuffle(double[][] a, long from, long to, java.util.Random random)
a
- the big array to be shuffled.from
- the index of the first element (inclusive) to be shuffled.to
- the index of the last element (exclusive) to be shuffled.random
- a pseudorandom number generator.a
.public static double[][] shuffle(double[][] a, java.util.Random random)
a
- the big array to be shuffled.random
- a pseudorandom number generator.a
.public static boolean get(boolean[][] array, long index)
array
- a big array.index
- a position in the big array.public static void set(boolean[][] array, long index, boolean value)
array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.public static void swap(boolean[][] array, long first, long second)
array
- a big array.first
- a position in the big array.second
- a position in the big array.public static boolean[][] reverse(boolean[][] a)
a
- the big array to be reversed.a
.public static long length(boolean[][] array)
array
- a big array.public static void copy(boolean[][] srcArray, long srcPos, boolean[][] destArray, long destPos, long length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyFromBig(boolean[][] srcArray, long srcPos, boolean[] destArray, int destPos, int length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyToBig(boolean[] srcArray, int srcPos, boolean[][] destArray, long destPos, long length)
srcArray
- the source array.srcPos
- the starting position in the source array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static boolean[][] wrap(boolean[] array)
Note that the returned big array might contain as a segment the original array.
array
- an array.array
.public static boolean[][] ensureCapacity(boolean[][] array, long length)
If you cannot foresee whether this big array will need again to be
enlarged, you should probably use grow()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it contains length
entries or more; otherwise,
a big array with length
entries whose first length(array)
entries are the same as those of array
.public static boolean[][] forceCapacity(boolean[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.length
entries whose first preserve
entries are the same as those of array
.public static boolean[][] ensureCapacity(boolean[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries or more; otherwise,
a big array with length
entries whose first preserve
entries are the same as those of array
.public static boolean[][] grow(boolean[][] array, long length)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
length(array)
entries are the same as those of array
.public static boolean[][] grow(boolean[][] array, long length, long preserve)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
preserve
entries are the same as those of array
.public static boolean[][] trim(boolean[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new maximum length for the big array.array
, if it contains length
entries or less; otherwise, a big array with
length
entries whose entries are the same as
the first length
entries of array
.public static boolean[][] setLength(boolean[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new length for the big array.array
, if it contains exactly length
entries; otherwise, if it contains more than
length
entries, a big array with length
entries
whose entries are the same as the first length
entries of
array
; otherwise, a big array with length
entries
whose first length(array)
entries are the same as those of
array
.public static boolean[][] copy(boolean[][] array, long offset, long length)
array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.public static boolean[][] copy(boolean[][] array)
array
- a big array.array
.public static void fill(boolean[][] array, boolean value)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
array
- a big array.value
- the new value for all elements of the big array.public static void fill(boolean[][] array, long from, long to, boolean value)
If possible (i.e., from
is 0) this method uses a
backward loop. In this case, it is significantly faster than the
corresponding method in Arrays
.
array
- a big array.from
- the starting index of the portion to fill.to
- the end index of the portion to fill.value
- the new value for all elements of the specified portion of the big array.public static boolean equals(boolean[][] a1, boolean[][] a2)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.public static java.lang.String toString(boolean[][] a)
public static void ensureFromTo(boolean[][] a, long from, long to)
This method may be used whenever a big array range check is needed.
a
- a big array.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than the big array length or negative.public static void ensureOffsetLength(boolean[][] a, long offset, long length)
This method may be used whenever a big array range check is needed.
a
- a big array.offset
- a start index.length
- a length (the number of elements in the range).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+length
is greater than the big array length.public static void ensureSameLength(boolean[][] a, boolean[][] b)
a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static boolean[][] shuffle(boolean[][] a, long from, long to, java.util.Random random)
a
- the big array to be shuffled.from
- the index of the first element (inclusive) to be shuffled.to
- the index of the last element (exclusive) to be shuffled.random
- a pseudorandom number generator.a
.public static boolean[][] shuffle(boolean[][] a, java.util.Random random)
a
- the big array to be shuffled.random
- a pseudorandom number generator.a
.public static short get(short[][] array, long index)
array
- a big array.index
- a position in the big array.public static void set(short[][] array, long index, short value)
array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.public static void swap(short[][] array, long first, long second)
array
- a big array.first
- a position in the big array.second
- a position in the big array.public static short[][] reverse(short[][] a)
a
- the big array to be reversed.a
.public static void add(short[][] array, long index, short incr)
array
- a big array.index
- a position in the big array.incr
- the incrementpublic static void mul(short[][] array, long index, short factor)
array
- a big array.index
- a position in the big array.factor
- the factorpublic static void incr(short[][] array, long index)
array
- a big array.index
- a position in the big array.public static void decr(short[][] array, long index)
array
- a big array.index
- a position in the big array.public static long length(short[][] array)
array
- a big array.public static void copy(short[][] srcArray, long srcPos, short[][] destArray, long destPos, long length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyFromBig(short[][] srcArray, long srcPos, short[] destArray, int destPos, int length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyToBig(short[] srcArray, int srcPos, short[][] destArray, long destPos, long length)
srcArray
- the source array.srcPos
- the starting position in the source array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static short[][] wrap(short[] array)
Note that the returned big array might contain as a segment the original array.
array
- an array.array
.public static short[][] ensureCapacity(short[][] array, long length)
If you cannot foresee whether this big array will need again to be
enlarged, you should probably use grow()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it contains length
entries or more; otherwise,
a big array with length
entries whose first length(array)
entries are the same as those of array
.public static short[][] forceCapacity(short[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.length
entries whose first preserve
entries are the same as those of array
.public static short[][] ensureCapacity(short[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries or more; otherwise,
a big array with length
entries whose first preserve
entries are the same as those of array
.public static short[][] grow(short[][] array, long length)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
length(array)
entries are the same as those of array
.public static short[][] grow(short[][] array, long length, long preserve)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
preserve
entries are the same as those of array
.public static short[][] trim(short[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new maximum length for the big array.array
, if it contains length
entries or less; otherwise, a big array with
length
entries whose entries are the same as
the first length
entries of array
.public static short[][] setLength(short[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new length for the big array.array
, if it contains exactly length
entries; otherwise, if it contains more than
length
entries, a big array with length
entries
whose entries are the same as the first length
entries of
array
; otherwise, a big array with length
entries
whose first length(array)
entries are the same as those of
array
.public static short[][] copy(short[][] array, long offset, long length)
array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.public static short[][] copy(short[][] array)
array
- a big array.array
.public static void fill(short[][] array, short value)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
array
- a big array.value
- the new value for all elements of the big array.public static void fill(short[][] array, long from, long to, short value)
If possible (i.e., from
is 0) this method uses a
backward loop. In this case, it is significantly faster than the
corresponding method in Arrays
.
array
- a big array.from
- the starting index of the portion to fill.to
- the end index of the portion to fill.value
- the new value for all elements of the specified portion of the big array.public static boolean equals(short[][] a1, short[][] a2)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.public static java.lang.String toString(short[][] a)
public static void ensureFromTo(short[][] a, long from, long to)
This method may be used whenever a big array range check is needed.
a
- a big array.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than the big array length or negative.public static void ensureOffsetLength(short[][] a, long offset, long length)
This method may be used whenever a big array range check is needed.
a
- a big array.offset
- a start index.length
- a length (the number of elements in the range).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+length
is greater than the big array length.public static void ensureSameLength(short[][] a, short[][] b)
a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static short[][] shuffle(short[][] a, long from, long to, java.util.Random random)
a
- the big array to be shuffled.from
- the index of the first element (inclusive) to be shuffled.to
- the index of the last element (exclusive) to be shuffled.random
- a pseudorandom number generator.a
.public static short[][] shuffle(short[][] a, java.util.Random random)
a
- the big array to be shuffled.random
- a pseudorandom number generator.a
.public static char get(char[][] array, long index)
array
- a big array.index
- a position in the big array.public static void set(char[][] array, long index, char value)
array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.public static void swap(char[][] array, long first, long second)
array
- a big array.first
- a position in the big array.second
- a position in the big array.public static char[][] reverse(char[][] a)
a
- the big array to be reversed.a
.public static void add(char[][] array, long index, char incr)
array
- a big array.index
- a position in the big array.incr
- the incrementpublic static void mul(char[][] array, long index, char factor)
array
- a big array.index
- a position in the big array.factor
- the factorpublic static void incr(char[][] array, long index)
array
- a big array.index
- a position in the big array.public static void decr(char[][] array, long index)
array
- a big array.index
- a position in the big array.public static long length(char[][] array)
array
- a big array.public static void copy(char[][] srcArray, long srcPos, char[][] destArray, long destPos, long length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyFromBig(char[][] srcArray, long srcPos, char[] destArray, int destPos, int length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyToBig(char[] srcArray, int srcPos, char[][] destArray, long destPos, long length)
srcArray
- the source array.srcPos
- the starting position in the source array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static char[][] wrap(char[] array)
Note that the returned big array might contain as a segment the original array.
array
- an array.array
.public static char[][] ensureCapacity(char[][] array, long length)
If you cannot foresee whether this big array will need again to be
enlarged, you should probably use grow()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it contains length
entries or more; otherwise,
a big array with length
entries whose first length(array)
entries are the same as those of array
.public static char[][] forceCapacity(char[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.length
entries whose first preserve
entries are the same as those of array
.public static char[][] ensureCapacity(char[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries or more; otherwise,
a big array with length
entries whose first preserve
entries are the same as those of array
.public static char[][] grow(char[][] array, long length)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
length(array)
entries are the same as those of array
.public static char[][] grow(char[][] array, long length, long preserve)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
preserve
entries are the same as those of array
.public static char[][] trim(char[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new maximum length for the big array.array
, if it contains length
entries or less; otherwise, a big array with
length
entries whose entries are the same as
the first length
entries of array
.public static char[][] setLength(char[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new length for the big array.array
, if it contains exactly length
entries; otherwise, if it contains more than
length
entries, a big array with length
entries
whose entries are the same as the first length
entries of
array
; otherwise, a big array with length
entries
whose first length(array)
entries are the same as those of
array
.public static char[][] copy(char[][] array, long offset, long length)
array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.public static char[][] copy(char[][] array)
array
- a big array.array
.public static void fill(char[][] array, char value)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
array
- a big array.value
- the new value for all elements of the big array.public static void fill(char[][] array, long from, long to, char value)
If possible (i.e., from
is 0) this method uses a
backward loop. In this case, it is significantly faster than the
corresponding method in Arrays
.
array
- a big array.from
- the starting index of the portion to fill.to
- the end index of the portion to fill.value
- the new value for all elements of the specified portion of the big array.public static boolean equals(char[][] a1, char[][] a2)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.public static java.lang.String toString(char[][] a)
public static void ensureFromTo(char[][] a, long from, long to)
This method may be used whenever a big array range check is needed.
a
- a big array.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than the big array length or negative.public static void ensureOffsetLength(char[][] a, long offset, long length)
This method may be used whenever a big array range check is needed.
a
- a big array.offset
- a start index.length
- a length (the number of elements in the range).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+length
is greater than the big array length.public static void ensureSameLength(char[][] a, char[][] b)
a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static char[][] shuffle(char[][] a, long from, long to, java.util.Random random)
a
- the big array to be shuffled.from
- the index of the first element (inclusive) to be shuffled.to
- the index of the last element (exclusive) to be shuffled.random
- a pseudorandom number generator.a
.public static char[][] shuffle(char[][] a, java.util.Random random)
a
- the big array to be shuffled.random
- a pseudorandom number generator.a
.public static float get(float[][] array, long index)
array
- a big array.index
- a position in the big array.public static void set(float[][] array, long index, float value)
array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.public static void swap(float[][] array, long first, long second)
array
- a big array.first
- a position in the big array.second
- a position in the big array.public static float[][] reverse(float[][] a)
a
- the big array to be reversed.a
.public static void add(float[][] array, long index, float incr)
array
- a big array.index
- a position in the big array.incr
- the incrementpublic static void mul(float[][] array, long index, float factor)
array
- a big array.index
- a position in the big array.factor
- the factorpublic static void incr(float[][] array, long index)
array
- a big array.index
- a position in the big array.public static void decr(float[][] array, long index)
array
- a big array.index
- a position in the big array.public static long length(float[][] array)
array
- a big array.public static void copy(float[][] srcArray, long srcPos, float[][] destArray, long destPos, long length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyFromBig(float[][] srcArray, long srcPos, float[] destArray, int destPos, int length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static void copyToBig(float[] srcArray, int srcPos, float[][] destArray, long destPos, long length)
srcArray
- the source array.srcPos
- the starting position in the source array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static float[][] wrap(float[] array)
Note that the returned big array might contain as a segment the original array.
array
- an array.array
.public static float[][] ensureCapacity(float[][] array, long length)
If you cannot foresee whether this big array will need again to be
enlarged, you should probably use grow()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it contains length
entries or more; otherwise,
a big array with length
entries whose first length(array)
entries are the same as those of array
.public static float[][] forceCapacity(float[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.length
entries whose first preserve
entries are the same as those of array
.public static float[][] ensureCapacity(float[][] array, long length, long preserve)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries or more; otherwise,
a big array with length
entries whose first preserve
entries are the same as those of array
.public static float[][] grow(float[][] array, long length)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
length(array)
entries are the same as those of array
.public static float[][] grow(float[][] array, long length, long preserve)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
preserve
entries are the same as those of array
.public static float[][] trim(float[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new maximum length for the big array.array
, if it contains length
entries or less; otherwise, a big array with
length
entries whose entries are the same as
the first length
entries of array
.public static float[][] setLength(float[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new length for the big array.array
, if it contains exactly length
entries; otherwise, if it contains more than
length
entries, a big array with length
entries
whose entries are the same as the first length
entries of
array
; otherwise, a big array with length
entries
whose first length(array)
entries are the same as those of
array
.public static float[][] copy(float[][] array, long offset, long length)
array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.public static float[][] copy(float[][] array)
array
- a big array.array
.public static void fill(float[][] array, float value)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
array
- a big array.value
- the new value for all elements of the big array.public static void fill(float[][] array, long from, long to, float value)
If possible (i.e., from
is 0) this method uses a
backward loop. In this case, it is significantly faster than the
corresponding method in Arrays
.
array
- a big array.from
- the starting index of the portion to fill.to
- the end index of the portion to fill.value
- the new value for all elements of the specified portion of the big array.public static boolean equals(float[][] a1, float[][] a2)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.public static java.lang.String toString(float[][] a)
public static void ensureFromTo(float[][] a, long from, long to)
This method may be used whenever a big array range check is needed.
a
- a big array.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than the big array length or negative.public static void ensureOffsetLength(float[][] a, long offset, long length)
This method may be used whenever a big array range check is needed.
a
- a big array.offset
- a start index.length
- a length (the number of elements in the range).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+length
is greater than the big array length.public static void ensureSameLength(float[][] a, float[][] b)
a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static float[][] shuffle(float[][] a, long from, long to, java.util.Random random)
a
- the big array to be shuffled.from
- the index of the first element (inclusive) to be shuffled.to
- the index of the last element (exclusive) to be shuffled.random
- a pseudorandom number generator.a
.public static float[][] shuffle(float[][] a, java.util.Random random)
a
- the big array to be shuffled.random
- a pseudorandom number generator.a
.public static <K> K get(K[][] array, long index)
array
- a big array.index
- a position in the big array.public static <K> void set(K[][] array, long index, K value)
array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.public static <K> void swap(K[][] array, long first, long second)
array
- a big array.first
- a position in the big array.second
- a position in the big array.public static <K> K[][] reverse(K[][] a)
a
- the big array to be reversed.a
.public static <K> long length(K[][] array)
array
- a big array.public static <K> void copy(K[][] srcArray, long srcPos, K[][] destArray, long destPos, long length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static <K> void copyFromBig(K[][] srcArray, long srcPos, K[] destArray, int destPos, int length)
srcArray
- the source big array.srcPos
- the starting position in the source big array.destArray
- the destination array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static <K> void copyToBig(K[] srcArray, int srcPos, K[][] destArray, long destPos, long length)
srcArray
- the source array.srcPos
- the starting position in the source array.destArray
- the destination big array.destPos
- the starting position in the destination data.length
- the number of elements to be copied.public static <K> K[][] wrap(K[] array)
Note that the returned big array might contain as a segment the original array.
array
- an array.array
.public static <K> K[][] ensureCapacity(K[][] array, long length)
If you cannot foresee whether this big array will need again to be
enlarged, you should probably use grow()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it contains length
entries or more; otherwise,
a big array with length
entries whose first length(array)
entries are the same as those of array
.public static <K> K[][] forceCapacity(K[][] array, long length, long preserve)
This method returns a new big array of the given length whose element
are of the same class as of those of array
.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.length
entries whose first preserve
entries are the same as those of array
.public static <K> K[][] ensureCapacity(K[][] array, long length, long preserve)
This method returns a new big array of the given length whose element
are of the same class as of those of array
.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries or more; otherwise,
a big array with length
entries whose first preserve
entries are the same as those of array
.public static <K> K[][] grow(K[][] array, long length)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
length(array)
entries are the same as those of array
.public static <K> K[][] grow(K[][] array, long length, long preserve)
If you want complete control on the big array growth, you
should probably use ensureCapacity()
instead.
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new minimum length for this big array.preserve
- the number of elements of the big array that must be preserved in case a new allocation is necessary.array
, if it can contain length
entries; otherwise, a big array with
max(length
,length(array)
/φ) entries whose first
preserve
entries are the same as those of array
.public static <K> K[][] trim(K[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new maximum length for the big array.array
, if it contains length
entries or less; otherwise, a big array with
length
entries whose entries are the same as
the first length
entries of array
.public static <K> K[][] setLength(K[][] array, long length)
Warning: the returned array might use part of the segments of the original array, which must be considered read-only after calling this method.
array
- a big array.length
- the new length for the big array.array
, if it contains exactly length
entries; otherwise, if it contains more than
length
entries, a big array with length
entries
whose entries are the same as the first length
entries of
array
; otherwise, a big array with length
entries
whose first length(array)
entries are the same as those of
array
.public static <K> K[][] copy(K[][] array, long offset, long length)
array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.public static <K> K[][] copy(K[][] array)
array
- a big array.array
.public static <K> void fill(K[][] array, K value)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
array
- a big array.value
- the new value for all elements of the big array.public static <K> void fill(K[][] array, long from, long to, K value)
If possible (i.e., from
is 0) this method uses a
backward loop. In this case, it is significantly faster than the
corresponding method in Arrays
.
array
- a big array.from
- the starting index of the portion to fill.to
- the end index of the portion to fill.value
- the new value for all elements of the specified portion of the big array.public static <K> boolean equals(K[][] a1, K[][] a2)
This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.public static <K> java.lang.String toString(K[][] a)
public static <K> void ensureFromTo(K[][] a, long from, long to)
This method may be used whenever a big array range check is needed.
a
- a big array.from
- a start index (inclusive).to
- an end index (inclusive).java.lang.IllegalArgumentException
- if from
is greater than to
.java.lang.ArrayIndexOutOfBoundsException
- if from
or to
are greater than the big array length or negative.public static <K> void ensureOffsetLength(K[][] a, long offset, long length)
This method may be used whenever a big array range check is needed.
a
- a big array.offset
- a start index.length
- a length (the number of elements in the range).java.lang.IllegalArgumentException
- if length
is negative.java.lang.ArrayIndexOutOfBoundsException
- if offset
is negative or offset
+length
is greater than the big array length.public static <K> void ensureSameLength(K[][] a, K[][] b)
a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static <K> K[][] shuffle(K[][] a, long from, long to, java.util.Random random)
a
- the big array to be shuffled.from
- the index of the first element (inclusive) to be shuffled.to
- the index of the last element (exclusive) to be shuffled.random
- a pseudorandom number generator.a
.public static <K> K[][] shuffle(K[][] a, java.util.Random random)
a
- the big array to be shuffled.random
- a pseudorandom number generator.a
.public static void main(java.lang.String[] arg)