public class Ranks extends Object
Arrays.sort(Object[])
does, and in addition return the
index that each element had in the original array prior the sorting.
Every methods are used in the same way:
whereint[] index = ranks(source, target);
source
and target
are arrays of Comparable
elements or of a
primitive type. The source
argument is the array to sort and is left untouched (unless
target
is a reference to the same array). The target
argument, if nonnull, is
the array where to store the sorted values.
The returned index
array will have the same length than the source
array. Each
element in the returned array is an index ranging from 0 inclusive to source.length
exclusive, such that target[i]
= source[index[i]]
for all i.
Invoking ranks(source, source)
is
equivalent to invoking Arrays.sort(source)
in a
less efficient way. The later should always be used (cloning the source array if needed) if the
returned ranks are not used.
Modifier and Type  Method and Description 

static int[] 
ranks(byte[] source,
byte[] target)
Sorts the elements in the given array and return their ranks.

static int[] 
ranks(double[] source,
double[] target)
Sorts the elements in the given array and return their ranks.

static int[] 
ranks(float[] source,
float[] target)
Sorts the elements in the given array and return their ranks.

static int[] 
ranks(int[] source,
int[] target)
Sorts the elements in the given array and return their ranks.

static int[] 
ranks(long[] source,
long[] target)
Sorts the elements in the given array and return their ranks.

static int[] 
ranks(short[] source,
short[] target)
Sorts the elements in the given array and return their ranks.

static <T extends Comparable<T>> 
ranks(T[] source,
T[] target)
Sorts the elements in the given array and return their ranks.

public static <T extends Comparable<T>> int[] ranks(T[] source, T[] target)
T
 The type of elements in the array to be sorted.source
 The array of values to sort, or null
.target
 The array where to store sorted values, or null
if none. May be the
same array than source
, in which case the sorting will be performed in place.null
if source
was null.Arrays.sort(Object[])
public static int[] ranks(double[] source, double[] target)
source
 The array of values to sort, or null
.target
 The array where to store sorted values, or null
if none. May be the
same array than source
, in which case the sorting will be performed in place.null
if source
was null.Arrays.sort(double[])
public static int[] ranks(float[] source, float[] target)
source
 The array of values to sort, or null
.target
 The array where to store sorted values, or null
if none. May be the
same array than source
, in which case the sorting will be performed in place.null
if source
was null.Arrays.sort(float[])
public static int[] ranks(long[] source, long[] target)
source
 The array of values to sort, or null
.target
 The array where to store sorted values, or null
if none. May be the
same array than source
, in which case the sorting will be performed in place.null
if source
was null.Arrays.sort(long[])
public static int[] ranks(int[] source, int[] target)
source
 The array of values to sort, or null
.target
 The array where to store sorted values, or null
if none. May be the
same array than source
, in which case the sorting will be performed in place.null
if source
was null.Arrays.sort(int[])
public static int[] ranks(short[] source, short[] target)
source
 The array of values to sort, or null
.target
 The array where to store sorted values, or null
if none. May be the
same array than source
, in which case the sorting will be performed in place.null
if source
was null.Arrays.sort(short[])
public static int[] ranks(byte[] source, byte[] target)
source
 The array of values to sort, or null
.target
 The array where to store sorted values, or null
if none. May be the
same array than source
, in which case the sorting will be performed in place.null
if source
was null.Arrays.sort(byte[])
Copyright © 1996–2021 Geotools. All rights reserved.