Class KthElement
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidkthElement(int k, byte[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int k, char[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int k, double[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int k, float[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int k, int[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int i, int j, int k, byte[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int i, int j, int k, char[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int i, int j, int k, double[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int i, int j, int k, float[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int i, int j, int k, int[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int i, int j, int k, long[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int i, int j, int k, short[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static <T extends Comparable<T>>
voidkthElement(int i, int j, int k, List<T> values) Partition a sublist ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static <T extends Comparable<T>>
voidkthElement(int i, int j, int k, List<T> values, int[] permutation) Partition a sublist ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static <T> voidkthElement(int i, int j, int k, List<T> values, int[] permutation, Comparator<? super T> comparator) Partition a sublist ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static <T> voidkthElement(int i, int j, int k, List<T> values, Comparator<? super T> comparator) Partition a sublist ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int k, long[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static voidkthElement(int k, short[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static <T extends Comparable<T>>
voidkthElement(int k, List<T> values) Partition a list ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static <T extends Comparable<T>>
voidkthElement(int k, List<T> values, int[] permutation) Partition a list ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static <T> voidkthElement(int k, List<T> values, int[] permutation, Comparator<? super T> comparator) Partition a list ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static <T> voidkthElement(int k, List<T> values, Comparator<? super T> comparator) Partition a list ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.static <T extends Comparable<T>>
voidkthElement(ListIterator<T> i, ListIterator<T> j, int k) Partition a sublist such that the k-th smallest value is at positionk, elements before the k-th are smaller or equal, and elements after the k-th are larger or equal.static <T extends Comparable<T>>
voidkthElement(ListIterator<T> i, ListIterator<T> j, int k, int[] permutation) Partition a sublist such that the k-th smallest value is at positionk, elements before the k-th are smaller or equal, and elements after the k-th are larger or equal.static <T> voidkthElement(ListIterator<T> i, ListIterator<T> j, int k, int[] permutation, Comparator<? super T> comparator) Partition a sublist such that the k-th smallest value is at positionk, elements before the k-th are smaller or equal, and elements after the k-th are larger or equal.static <T> voidkthElement(ListIterator<T> i, ListIterator<T> j, int k, Comparator<? super T> comparator) Partition a sublist such that the k-th smallest value is at positionk, elements before the k-th are smaller or equal, and elements after the k-th are larger or equal.
-
Constructor Details
-
KthElement
public KthElement()
-
-
Method Details
-
kthElement
public static void kthElement(int i, int j, int k, byte[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- array
-
kthElement
public static void kthElement(int k, byte[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
k- index for k-th smallest value.0 <= k < values.length.values- array
-
kthElement
public static void kthElement(int i, int j, int k, short[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- array
-
kthElement
public static void kthElement(int k, short[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
k- index for k-th smallest value.0 <= k < values.length.values- array
-
kthElement
public static void kthElement(int i, int j, int k, int[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- array
-
kthElement
public static void kthElement(int k, int[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
k- index for k-th smallest value.0 <= k < values.length.values- array
-
kthElement
public static void kthElement(int i, int j, int k, long[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- array
-
kthElement
public static void kthElement(int k, long[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
k- index for k-th smallest value.0 <= k < values.length.values- array
-
kthElement
public static void kthElement(int i, int j, int k, float[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- array
-
kthElement
public static void kthElement(int k, float[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
k- index for k-th smallest value.0 <= k < values.length.values- array
-
kthElement
public static void kthElement(int i, int j, int k, double[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- array
-
kthElement
public static void kthElement(int k, double[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
k- index for k-th smallest value.0 <= k < values.length.values- array
-
kthElement
public static void kthElement(int i, int j, int k, char[] values) Partition a subarray ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- array
-
kthElement
public static void kthElement(int k, char[] values) Partition an array ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
k- index for k-th smallest value.0 <= k < values.length.values- array
-
kthElement
public static <T> void kthElement(int i, int j, int k, List<T> values, Comparator<? super T> comparator) Partition a sublist ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- arraycomparator- ordering function on T
-
kthElement
Partition a list ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
k- index for k-th smallest value.0 <= k < values.size().values- arraycomparator- ordering function on T
-
kthElement
Partition a sublist ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- array
-
kthElement
Partition a list ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.- Parameters:
k- index for k-th smallest value.0 <= k < values.size().values- array
-
kthElement
public static <T> void kthElement(ListIterator<T> i, ListIterator<T> j, int k, Comparator<? super T> comparator) Partition a sublist such that the k-th smallest value is at positionk, elements before the k-th are smaller or equal, and elements after the k-th are larger or equal.After the function returns, the iterator
iis on the k-th element. That is,i.next()gives the (k+1)-th element.- Parameters:
i- iterator pointing before first element of the sublist, that is,i.next()gives you the first element.j- iterator pointing behind the last element of the sublist, that is,i.previous()gives you the last element.k- index for k-th smallest value.i.nextIndex() <= k <= j.previousIndex().comparator- ordering function on T
-
kthElement
public static <T extends Comparable<T>> void kthElement(ListIterator<T> i, ListIterator<T> j, int k) Partition a sublist such that the k-th smallest value is at positionk, elements before the k-th are smaller or equal, and elements after the k-th are larger or equal.After the function returns, the iterator
iis on the k-th element. That is,i.next()gives the (k+1)-th element.- Parameters:
i- iterator pointing before first element of the sublist, that is,i.next()gives you the first element.j- iterator pointing behind the last element of the sublist, that is,i.previous()gives you the last element.k- index for k-th smallest value.i.nextIndex() <= k <= j.previousIndex().
-
kthElement
public static <T> void kthElement(int i, int j, int k, List<T> values, int[] permutation, Comparator<? super T> comparator) Partition a sublist ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.The
permutationarray is permuted in the same way as the list. Usually, this will be an array of indices, so that the partition operation can be mirrored in another list: Suppose, we have a list of keys and a lists (or several) of values. If we usekthElementto sort the keys, we want to reorder the values in the same manner. We pass an indices array [0, 1, 2, ...] and use the permutation of the indices to permute the values list.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- arraypermutation- elements of this array are permuted in the same way as the elements in the values listcomparator- ordering function on T
-
kthElement
public static <T> void kthElement(int k, List<T> values, int[] permutation, Comparator<? super T> comparator) Partition a list ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.The
permutationarray is permuted in the same way as the list. Usually, this will be an array of indices, so that the partition operation can be mirrored in another list: Suppose, we have a list of keys and a lists (or several) of values. If we usekthElementto sort the keys, we want to reorder the values in the same manner. We pass an indices array [0, 1, 2, ...] and use the permutation of the indices to permute the values list.- Parameters:
k- index for k-th smallest value.0 <= k < values.size().values- arraypermutation- elements of this array are permuted in the same way as the elements in the values listcomparator- ordering function on T
-
kthElement
public static <T extends Comparable<T>> void kthElement(int i, int j, int k, List<T> values, int[] permutation) Partition a sublist ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.The
permutationarray is permuted in the same way as the list. Usually, this will be an array of indices, so that the partition operation can be mirrored in another list: Suppose, we have a list of keys and a lists (or several) of values. If we usekthElementto sort the keys, we want to reorder the values in the same manner. We pass an indices array [0, 1, 2, ...] and use the permutation of the indices to permute the values list.- Parameters:
i- index of first element of subarrayj- index of last element of subarrayk- index for k-th smallest value.i <= k <= j.values- arraypermutation- elements of this array are permuted in the same way as the elements in the values list
-
kthElement
Partition a list ofvaluessuch that the k-th smallest value is at positionk, elements before the k-th are smaller or equal and elements after the k-th are larger or equal.The
permutationarray is permuted in the same way as the list. Usually, this will be an array of indices, so that the partition operation can be mirrored in another list: Suppose, we have a list of keys and a lists (or several) of values. If we usekthElementto sort the keys, we want to reorder the values in the same manner. We pass an indices array [0, 1, 2, ...] and use the permutation of the indices to permute the values list.- Parameters:
k- index for k-th smallest value.0 <= k < values.size().values- arraypermutation- elements of this array are permuted in the same way as the elements in the values list
-
kthElement
public static <T> void kthElement(ListIterator<T> i, ListIterator<T> j, int k, int[] permutation, Comparator<? super T> comparator) Partition a sublist such that the k-th smallest value is at positionk, elements before the k-th are smaller or equal, and elements after the k-th are larger or equal.After the function returns, the iterator
iis on the k-th element. That is,i.next()gives the (k+1)-th element.The
permutationarray is permuted in the same way as the list. Usually, this will be an array of indices, so that the partition operation can be mirrored in another list: Suppose, we have a list of keys and a lists (or several) of values. If we usekthElementto sort the keys, we want to reorder the values in the same manner. We pass an indices array [0, 1, 2, ...] and use the permutation of the indices to permute the values list.- Parameters:
i- iterator pointing before first element of the sublist, that is,i.next()gives you the first element.j- iterator pointing behind the last element of the sublist, that is,i.previous()gives you the last element.k- index for k-th smallest value.i.nextIndex() <= k <= j.previousIndex().permutation- elements of this array are permuted in the same way as the elements in the values listcomparator- ordering function on T
-
kthElement
public static <T extends Comparable<T>> void kthElement(ListIterator<T> i, ListIterator<T> j, int k, int[] permutation) Partition a sublist such that the k-th smallest value is at positionk, elements before the k-th are smaller or equal, and elements after the k-th are larger or equal.After the function returns, the iterator
iis on the k-th element. That is,i.next()gives the (k+1)-th element.The
permutationarray is permuted in the same way as the list. Usually, this will be an array of indices, so that the partition operation can be mirrored in another list: Suppose, we have a list of keys and a lists (or several) of values. If we usekthElementto sort the keys, we want to reorder the values in the same manner. We pass an indices array [0, 1, 2, ...] and use the permutation of the indices to permute the values list.- Parameters:
i- iterator pointing before first element of the sublist, that is,i.next()gives you the first element.j- iterator pointing behind the last element of the sublist, that is,i.previous()gives you the last element.k- index for k-th smallest value.i.nextIndex() <= k <= j.previousIndex().permutation- elements of this array are permuted in the same way as the elements in the values list
-