Enum SortInPlace
- java.lang.Object
-
- java.lang.Enum<SortInPlace>
-
- org.apache.commons.numbers.arrays.SortInPlace
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<SortInPlace>
public enum SortInPlace extends java.lang.Enum<SortInPlace>
Sort an array and perform the same reordering of entries on other arrays. For example, ifx = [3, 1, 2]
y = [1, 2, 3]
z = [0, 5, 7]
Sort.ASCENDING.apply(x, y, z)
will update those arrays:x = [1, 2, 3]
y = [2, 3, 1]
z = [5, 7, 0]
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SortInPlace.PairDoubleInteger
Helper data structure holding a (double, integer) pair.
-
Enum Constant Summary
Enum Constants Enum Constant Description ASCENDING
Sort in ascending order.DESCENDING
Sort in descending order.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<SortInPlace.PairDoubleInteger>
comparator
Comparator.
-
Constructor Summary
Constructors Modifier Constructor Description private
SortInPlace(java.util.Comparator<SortInPlace.PairDoubleInteger> comparator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(double[] x, double[]... yList)
Sorts in place.static SortInPlace
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static SortInPlace[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
ASCENDING
public static final SortInPlace ASCENDING
Sort in ascending order.
-
DESCENDING
public static final SortInPlace DESCENDING
Sort in descending order.
-
-
Field Detail
-
comparator
private final java.util.Comparator<SortInPlace.PairDoubleInteger> comparator
Comparator.
-
-
Constructor Detail
-
SortInPlace
private SortInPlace(java.util.Comparator<SortInPlace.PairDoubleInteger> comparator)
- Parameters:
comparator
- Comparator.
-
-
Method Detail
-
values
public static SortInPlace[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (SortInPlace c : SortInPlace.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static SortInPlace valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
apply
public void apply(double[] x, double[]... yList)
Sorts in place.- Parameters:
x
- Array to be sorted and used as a pattern for permutation of the other arrays.yList
- Set of arrays whose permutations of entries will follow those performed onx
.- Throws:
java.lang.IllegalArgumentException
- if not all arrays have the same size.
-
-