Package io.trino.array
Class IntBigArrays
java.lang.Object
io.trino.array.IntBigArrays
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
displacement
(long index) Computes the displacement associated with a given index.static int
get
(int[][] array, long index) Returns the element of the given big array of specified index.static void
quickSort
(int[][] x, long from, long to, IntComparator comp) Sorts the specified range of elements according to the order induced by the specified comparator using quicksort.static int
segment
(long index) Computes the segment associated with a given index.static void
set
(int[][] array, long index, int value) Sets the element of the given big array of specified index.static void
swap
(int[][] array, long first, long second) Swaps the element of the given big array of specified indices.
-
Method Details
-
segment
public static int segment(long index) Computes the segment associated with a given index.- Parameters:
index
- an index into a big array.- Returns:
- the associated segment.
-
displacement
public static int displacement(long index) Computes the displacement associated with a given index.- Parameters:
index
- an index into a big array.- Returns:
- the associated displacement (in the associated segment).
-
get
public static int get(int[][] array, long index) Returns the element of the given big array of specified index.- Parameters:
array
- a big array.index
- a position in the big array.- Returns:
- the element of the big array at the specified position.
-
set
public static void set(int[][] array, long index, int value) Sets the element of the given big array of specified index.- Parameters:
array
- a big array.index
- a position in the big array.
-
swap
public static void swap(int[][] array, long first, long second) Swaps the element of the given big array of specified indices.- Parameters:
array
- a big array.first
- a position in the big array.second
- a position in the big array.
-
quickSort
Sorts the specified range of elements according to the order induced by the specified comparator using quicksort.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.
- Parameters:
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.
-