public final class FloatBigArrays
extends java.lang.Object
Note that BinIO
and TextIO
contain several methods that make it possible to load and save big arrays of primitive types as sequences
of elements in DataInput
format (i.e., not as objects) or as sequences of lines of text.
ForkJoinPool
that the operation should run in. For example,
something along the lines of "poolToParallelSortIn.invoke(() -> parallelQuickSort(arrayToSort))
"
will run the parallel sort in poolToParallelSortIn
instead of the default pool.BigArrays
Modifier and Type | Field and Description |
---|---|
static float[][] |
DEFAULT_EMPTY_BIG_ARRAY
A static, final, empty big array to be used as default big array in allocations.
|
static float[][] |
EMPTY_BIG_ARRAY
A static, final, empty big array.
|
static Hash.Strategy |
HASH_STRATEGY
A type-specific content-based hash strategy for big arrays.
|
Modifier and Type | Method and Description |
---|---|
static void |
add(float[][] array,
long index,
float incr)
Deprecated.
Please use the version in
BigArrays . |
static long |
binarySearch(float[][] a,
float key)
Searches a big array for the specified value using
the binary search algorithm.
|
static long |
binarySearch(float[][] a,
float key,
FloatComparator c)
Searches a big array for the specified value using
the binary search algorithm and a specified comparator.
|
static long |
binarySearch(float[][] a,
long from,
long to,
float key)
Searches a range of the specified big array for the specified value using
the binary search algorithm.
|
static long |
binarySearch(float[][] a,
long from,
long to,
float key,
FloatComparator c)
Searches a range of the specified big array for the specified value using
the binary search algorithm and a specified comparator.
|
static float[][] |
copy(float[][] array)
Deprecated.
Please use the version in
BigArrays . |
static void |
copy(float[][] srcArray,
long srcPos,
float[][] destArray,
long destPos,
long length)
Deprecated.
Please use the version in
BigArrays . |
static float[][] |
copy(float[][] array,
long offset,
long length)
Deprecated.
Please use the version in
BigArrays . |
static void |
copyFromBig(float[][] srcArray,
long srcPos,
float[] destArray,
int destPos,
int length)
Deprecated.
Please use the version in
BigArrays . |
static void |
copyToBig(float[] srcArray,
int srcPos,
float[][] destArray,
long destPos,
long length)
Deprecated.
Please use the version in
BigArrays . |
static void |
decr(float[][] array,
long index)
Deprecated.
Please use the version in
BigArrays . |
static float[][] |
ensureCapacity(float[][] array,
long length)
Deprecated.
Please use the version in
BigArrays . |
static float[][] |
ensureCapacity(float[][] array,
long length,
long preserve)
Deprecated.
Please use the version in
BigArrays . |
static void |
ensureFromTo(float[][] a,
long from,
long to)
Deprecated.
Please use the version in
BigArrays . |
static void |
ensureOffsetLength(float[][] a,
long offset,
long length)
Deprecated.
Please use the version in
BigArrays . |
static void |
ensureSameLength(float[][] a,
float[][] b)
Deprecated.
Please use the version in
BigArrays . |
static boolean |
equals(float[][] a1,
float[][] a2)
Deprecated.
Please use the version in
BigArrays . |
static void |
fill(float[][] array,
float value)
Deprecated.
Please use the version in
BigArrays . |
static void |
fill(float[][] array,
long from,
long to,
float value)
Deprecated.
Please use the version in
BigArrays . |
static float[][] |
forceCapacity(float[][] array,
long length,
long preserve)
Deprecated.
Please use the version in
BigArrays . |
static float |
get(float[][] array,
long index)
Deprecated.
Please use the version in
BigArrays . |
static float[][] |
grow(float[][] array,
long length)
Deprecated.
Please use the version in
BigArrays . |
static float[][] |
grow(float[][] array,
long length,
long preserve)
Deprecated.
Please use the version in
BigArrays . |
static void |
incr(float[][] array,
long index)
Deprecated.
Please use the version in
BigArrays . |
static long |
length(float[][] array)
Deprecated.
Please use the version in
BigArrays . |
static void |
mul(float[][] array,
long index,
float factor)
Deprecated.
Please use the version in
BigArrays . |
static float[][] |
newBigArray(long length)
Creates a new big array.
|
static void |
parallelQuickSort(float[][] x)
Sorts a big array according to the natural ascending order using a parallel quicksort.
|
static void |
parallelQuickSort(float[][] x,
FloatComparator comp)
Sorts a big array according to the order induced by the specified
comparator using a parallel quicksort.
|
static void |
parallelQuickSort(float[][] x,
long from,
long to)
Sorts the specified range of elements according to the natural ascending order using a parallel quicksort.
|
static void |
parallelQuickSort(float[][] x,
long from,
long to,
FloatComparator comp)
Sorts the specified range of elements according to the order induced by the specified
comparator using a parallel quicksort.
|
static void |
quickSort(float[][] x)
Sorts the specified big array according to the natural ascending order using quicksort.
|
static void |
quickSort(float[][] x,
FloatComparator comp)
Sorts the specified big array according to the order induced by the specified
comparator using quicksort.
|
static void |
quickSort(float[][] x,
long from,
long to)
Sorts the specified range of elements according to the natural ascending order using quicksort.
|
static void |
quickSort(float[][] x,
long from,
long to,
FloatComparator comp)
Sorts the specified range of elements according to the order induced by the specified
comparator using quicksort.
|
static void |
radixSort(float[][] a)
Sorts the specified big array using radix sort.
|
static void |
radixSort(float[][] a,
float[][] b)
Sorts the specified pair of big arrays lexicographically using radix sort.
|
static void |
radixSort(float[][] a,
float[][] b,
long from,
long to)
Sorts the specified pair of big arrays lexicographically using radix sort.
|
static void |
radixSort(float[][] a,
long from,
long to)
Sorts the specified big array using radix sort.
|
static void |
radixSortIndirect(long[][] perm,
float[][] a,
float[][] b,
boolean stable)
Sorts the specified pair of arrays lexicographically using indirect radix sort.
|
static void |
radixSortIndirect(long[][] perm,
float[][] a,
float[][] b,
long from,
long to,
boolean stable)
Sorts the specified pair of arrays lexicographically using indirect radix sort.
|
static void |
set(float[][] array,
long index,
float value)
Deprecated.
Please use the version in
BigArrays . |
static float[][] |
setLength(float[][] array,
long length)
Deprecated.
Please use the version in
BigArrays . |
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 void |
swap(float[][] array,
long first,
long second)
Deprecated.
Please use the version in
BigArrays . |
static java.lang.String |
toString(float[][] a)
Deprecated.
|
static float[][] |
trim(float[][] array,
long length)
Deprecated.
Please use the version in
BigArrays . |
static float[][] |
wrap(float[] array)
Deprecated.
Please use the version in
BigArrays . |
public static final float[][] EMPTY_BIG_ARRAY
public static final float[][] DEFAULT_EMPTY_BIG_ARRAY
EMPTY_BIG_ARRAY
makes it possible to have different
behaviors depending on whether the user required an empty allocation, or we are
just lazily delaying allocation.ArrayList
public static final Hash.Strategy HASH_STRATEGY
This hash strategy may be used in custom hash collections whenever keys are
big arrays, and they must be considered equal by content. This strategy
will handle null
correctly, and it is serializable.
@Deprecated public static float get(float[][] array, long index)
BigArrays
.array
- a big array.index
- a position in the big array.@Deprecated public static void set(float[][] array, long index, float value)
BigArrays
.array
- a big array.index
- a position in the big array.value
- the new value for the array element at the specified position.@Deprecated public static void swap(float[][] array, long first, long second)
BigArrays
.array
- a big array.first
- a position in the big array.second
- a position in the big array.@Deprecated public static void add(float[][] array, long index, float incr)
BigArrays
.array
- a big array.index
- a position in the big array.incr
- the increment@Deprecated public static void mul(float[][] array, long index, float factor)
BigArrays
.array
- a big array.index
- a position in the big array.factor
- the factor@Deprecated public static void incr(float[][] array, long index)
BigArrays
.array
- a big array.index
- a position in the big array.@Deprecated public static void decr(float[][] array, long index)
BigArrays
.array
- a big array.index
- a position in the big array.@Deprecated public static long length(float[][] array)
BigArrays
.array
- a big array.@Deprecated public static void copy(float[][] srcArray, long srcPos, float[][] destArray, long destPos, long length)
BigArrays
.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.@Deprecated public static void copyFromBig(float[][] srcArray, long srcPos, float[] destArray, int destPos, int length)
BigArrays
.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.@Deprecated public static void copyToBig(float[] srcArray, int srcPos, float[][] destArray, long destPos, long length)
BigArrays
.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[][] newBigArray(long length)
length
- the length of the new big array.@Deprecated public static float[][] wrap(float[] array)
BigArrays
.Note that the returned big array might contain as a segment the original array.
array
- an array.array
.@Deprecated public static float[][] ensureCapacity(float[][] array, long length)
BigArrays
.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
.@Deprecated public static float[][] forceCapacity(float[][] array, long length, long preserve)
BigArrays
.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
.@Deprecated public static float[][] ensureCapacity(float[][] array, long length, long preserve)
BigArrays
.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
.@Deprecated public static float[][] grow(float[][] array, long length)
BigArrays
.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
.@Deprecated public static float[][] grow(float[][] array, long length, long preserve)
BigArrays
.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
.@Deprecated public static float[][] trim(float[][] array, long length)
BigArrays
.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
.@Deprecated public static float[][] setLength(float[][] array, long length)
BigArrays
.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
.@Deprecated public static float[][] copy(float[][] array, long offset, long length)
BigArrays
.array
- a big array.offset
- the first element to copy.length
- the number of elements to copy.length
elements of array
starting at offset
.@Deprecated public static float[][] copy(float[][] array)
BigArrays
.array
- a big array.array
.@Deprecated public static void fill(float[][] array, float value)
BigArrays
.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.@Deprecated public static void fill(float[][] array, long from, long to, float value)
BigArrays
.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.@Deprecated public static boolean equals(float[][] a1, float[][] a2)
BigArrays
.This method uses a backward loop. It is significantly faster than the corresponding
method in Arrays
.
a1
- a big array.a2
- another big array.@Deprecated public static java.lang.String toString(float[][] a)
@Deprecated public static void ensureFromTo(float[][] a, long from, long to)
BigArrays
.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.@Deprecated public static void ensureOffsetLength(float[][] a, long offset, long length)
BigArrays
.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.@Deprecated public static void ensureSameLength(float[][] a, float[][] b)
BigArrays
.a
- a big array.b
- another big array.java.lang.IllegalArgumentException
- if the two argument arrays are not of the same length.public static void quickSort(float[][] x, long from, long to, FloatComparator comp)
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.
x
- the big array to be sorted.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 sorting order.public static void quickSort(float[][] x, FloatComparator comp)
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.
x
- the big array to be sorted.comp
- the comparator to determine the sorting order.public static void quickSort(float[][] x, long from, long to)
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.
x
- the big array to be sorted.from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (exclusive) to be sorted.public static void quickSort(float[][] x)
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.
x
- the big array to be sorted.public static void parallelQuickSort(float[][] x, long from, long to)
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.
x
- the big array to be sorted.from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (exclusive) to be sorted.public static void parallelQuickSort(float[][] x)
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.
x
- the big array to be sorted.public static void parallelQuickSort(float[][] x, long from, long to, FloatComparator comp)
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.
x
- the big array to be sorted.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 sorting order.public static void parallelQuickSort(float[][] x, FloatComparator comp)
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.
x
- the big array to be sorted.comp
- the comparator to determine the sorting order.public static long binarySearch(float[][] a, long from, long to, float key)
a
- the big array to be searched.from
- the index of the first element (inclusive) to be searched.to
- the index of the last element (exclusive) to be searched.key
- the value to be searched for.(-(insertion point) - 1)
. The insertion
point is defined as the the point at which the value would
be inserted into the big array: the index of the first
element greater than the key, or the length of the big array, if all
elements in the big array are less than the specified key. Note
that this guarantees that the return value will be >= 0 if
and only if the key is found.Arrays
public static long binarySearch(float[][] a, float key)
a
- the big array to be searched.key
- the value to be searched for.(-(insertion point) - 1)
. The insertion
point is defined as the the point at which the value would
be inserted into the big array: the index of the first
element greater than the key, or the length of the big array, if all
elements in the big array are less than the specified key. Note
that this guarantees that the return value will be >= 0 if
and only if the key is found.Arrays
public static long binarySearch(float[][] a, long from, long to, float key, FloatComparator c)
a
- the big array to be searched.from
- the index of the first element (inclusive) to be searched.to
- the index of the last element (exclusive) to be searched.key
- the value to be searched for.c
- a comparator.(-(insertion point) - 1)
. The insertion
point is defined as the the point at which the value would
be inserted into the big array: the index of the first
element greater than the key, or the length of the big array, if all
elements in the big array are less than the specified key. Note
that this guarantees that the return value will be >= 0 if
and only if the key is found.Arrays
public static long binarySearch(float[][] a, float key, FloatComparator c)
a
- the big array to be searched.key
- the value to be searched for.c
- a comparator.(-(insertion point) - 1)
. The insertion
point is defined as the the point at which the value would
be inserted into the big array: the index of the first
element greater than the key, or the length of the big array, if all
elements in the big array are less than the specified key. Note
that this guarantees that the return value will be >= 0 if
and only if the key is found.Arrays
public static void radixSort(float[][] a)
The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993), and further improved using the digit-oracle idea described by Juha Kärkkäinen and Tommi Rantala in “Engineering radix sort for strings”, String Processing and Information Retrieval, 15th International Symposium, volume 5280 of Lecture Notes in Computer Science, pages 3−14, Springer (2008).
a
- the big array to be sorted.public static void radixSort(float[][] a, long from, long to)
The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993), and further improved using the digit-oracle idea described by Juha Kärkkäinen and Tommi Rantala in “Engineering radix sort for strings”, String Processing and Information Retrieval, 15th International Symposium, volume 5280 of Lecture Notes in Computer Science, pages 3−14, Springer (2008).
a
- the big array to be sorted.from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (exclusive) to be sorted.public static void radixSort(float[][] a, float[][] b)
The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993), and further improved using the digit-oracle idea described by Juha Kärkkäinen and Tommi Rantala in “Engineering radix sort for strings”, String Processing and Information Retrieval, 15th International Symposium, volume 5280 of Lecture Notes in Computer Science, pages 3−14, Springer (2008).
This method implements a lexicographical sorting of the arguments. Pairs of elements
in the same position in the two provided arrays will be considered a single key, and permuted
accordingly. In the end, either a[i] < a[i + 1]
or a[i] == a[i + 1]
and b[i] <= b[i + 1]
.
a
- the first big array to be sorted.b
- the second big array to be sorted.public static void radixSort(float[][] a, float[][] b, long from, long to)
The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993), and further improved using the digit-oracle idea described by Juha Kärkkäinen and Tommi Rantala in “Engineering radix sort for strings”, String Processing and Information Retrieval, 15th International Symposium, volume 5280 of Lecture Notes in Computer Science, pages 3−14, Springer (2008).
This method implements a lexicographical sorting of the arguments. Pairs of elements
in the same position in the two provided arrays will be considered a single key, and permuted
accordingly. In the end, either a[i] < a[i + 1]
or a[i] == a[i + 1]
and b[i] <= b[i + 1]
.
a
- the first big array to be sorted.b
- the second big array to be sorted.from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (exclusive) to be sorted.public static void radixSortIndirect(long[][] perm, float[][] a, float[][] b, boolean stable)
The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).
This method implement an indirect sort. The elements of perm
(which must
be exactly the numbers in the interval [0..length(perm))
) will be permuted so that
a[perm[i]] ≤ a[perm[i + 1]]
or a[perm[i]] == a[perm[i + 1]]
and b[perm[i]] ≤ b[perm[i + 1]]
.
perm
- a permutation array indexing a
.a
- the array to be sorted.b
- the second array to be sorted.stable
- whether the sorting algorithm should be stable.perm
(note that the stable
version is slightly faster).public static void radixSortIndirect(long[][] perm, float[][] a, float[][] b, long from, long to, boolean stable)
The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).
This method implement an indirect sort. The elements of perm
(which must
be exactly the numbers in the interval [0..length(perm))
) will be permuted so that
a[perm[i]] ≤ a[perm[i + 1]]
or a[perm[i]] == a[perm[i + 1]]
and b[perm[i]] ≤ b[perm[i + 1]]
.
perm
- a permutation array indexing a
.a
- the array to be sorted.b
- the second array to be sorted.from
- the index of the first element of perm
(inclusive) to be permuted.to
- the index of the last element of perm
(exclusive) to be permuted.stable
- whether the sorting algorithm should be stable.perm
(note that the stable
version is slightly faster).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
.