public class Arrays extends Object
Modifier and Type | Method and Description |
---|---|
static int |
binarySearchNearest(double[] values,
double key)
|
static int |
binarySearchNearest(double[] values,
double key,
RoundingMode rm)
|
static int |
binarySearchNearest(double[] values,
int to,
int from,
double key)
|
static int |
binarySearchNearest(double[] values,
int from,
int to,
double key,
RoundingMode rm)
A variant of
Arrays.binarySearch(double[], int, int, double) that finds the array index with
value nearest to the given key, as determined by the provided RoundingMode . |
static int |
binarySearchNearest(int[] values,
int key)
A facade for
binarySearchNearest(int[], int, int, int, RoundingMode) . |
static int |
binarySearchNearest(int[] values,
int to,
int from,
int key)
A facade for
binarySearchNearest(int[], int, int, int, RoundingMode) . |
static int |
binarySearchNearest(int[] values,
int from,
int to,
int key,
RoundingMode rm)
A variant of
Arrays.binarySearch(int[], int, int, int) that finds the array index with value
nearest to the given key, as determined by the provided RoundingMode . |
static int |
binarySearchNearest(int[] values,
int key,
RoundingMode rm)
A facade for
binarySearchNearest(int[], int, int, int, RoundingMode) . |
static <T extends Comparable<? super T>> |
binarySearchNearest(List<? extends T> values,
T key)
A facade for
binarySearchNearest(List, Comparable, RoundingMode) . |
static <T> int |
binarySearchNearest(List<? extends T> values,
T key,
Comparator<? super T> c)
|
static <T> int |
binarySearchNearest(List<? extends T> values,
T key,
Comparator<? super T> c,
RoundingMode rm)
A variant of
Collections.binarySearch(List, Object, Comparator) that finds the array index with value
nearest to the given key, as determined by the provided RoundingMode . |
static <T extends Comparable<? super T>> |
binarySearchNearest(List<? extends T> values,
T key,
RoundingMode rm)
A variant of
Collections.binarySearch(List, Object) that finds the array index with value nearest to the
given key, as determined by the provided RoundingMode . |
static <T extends Comparable<? super T>> |
binarySearchNearest(T[] values,
int to,
int from,
T key)
|
static <T extends Comparable<? super T>> |
binarySearchNearest(T[] values,
int from,
int to,
T key,
RoundingMode rm)
A variant of
Arrays.binarySearch(Object[], int, int, Object) that finds the array index with
value nearest to the given key, as determined by the provided RoundingMode . |
static <T extends Comparable<? super T>> |
binarySearchNearest(T[] values,
T key)
|
static <T> int |
binarySearchNearest(T[] values,
T key,
Comparator<? super T> c)
A facade for
binarySearchNearest(Object[], Object, Comparator) . |
static <T> int |
binarySearchNearest(T[] values,
T key,
Comparator<? super T> c,
RoundingMode rm)
A variant of
Arrays.binarySearch(Object[], Object, Comparator) that finds the array index with
value nearest to the given key, as determined by the provided RoundingMode . |
static <T extends Comparable<? super T>> |
binarySearchNearest(T[] values,
T key,
RoundingMode rm)
|
static Double[] |
box(double[] values)
Boxes the given array of
double s. |
static Integer[] |
box(int[] values)
Boxes the given array of
int s. |
static int |
compare(double[] lhs,
double[] rhs)
Compares two arrays of
double s on the basis of lexicographic order. |
static int |
compare(int[] lhs,
int[] rhs)
Compares two arrays of
int s on the basis of lexicographic order. |
static <T extends Comparable<? super T>> |
compare(T[] lhs,
T[] rhs)
Compares two arrays of objects on the basis of lexicographic order.
|
static <T> int |
compare(T[] lhs,
T[] rhs,
Comparator<? super T> c)
Compares two arrays of objects on the basis of lexicographic order.
|
static <T> T[] |
newArray(Class<? extends T> clazz,
int length,
T value)
Creates a new array initialized to the given value.
|
static double[] |
newArray(int length,
double value)
Creates a new array initialized to the given value.
|
static int[] |
newArray(int length,
int value)
Creates a new array initialized to the given value.
|
static Object[] |
newArray(int length,
Object value)
Creates a new array initialized to the given value.
|
static double[] |
slice(double[] values,
int[] indices)
A convenience array slicing method.
|
static int[] |
slice(int[] values,
int[] indices)
A convenience array slicing method.
|
static <T> T[] |
slice(T[] values,
int[] indices,
Class<? extends T> clazz)
A convenience array slicing method.
|
static double[] |
unbox(Double[] values)
Unboxes the given array of
Double s. |
static int[] |
unbox(Integer[] values)
Unboxes the given array of
Integer s. |
static <T> T[] |
wrap(Class<T> clazz,
T value,
T... values)
Wraps the given value and trailing values as an array.
|
static <T> T[] |
wrap(T value,
T... values)
A facade for
wrap(Class, Object, Object...) . |
public static final int[] newArray(int length, int value)
public static final double[] newArray(int length, double value)
public static final Object[] newArray(int length, Object value)
public static final <T> T[] newArray(Class<? extends T> clazz, int length, T value)
T
- the component type.public static final double[] slice(double[] values, int[] indices)
values
- the values.indices
- the slice indices.public static final int[] slice(int[] values, int[] indices)
values
- the values.indices
- the slice indices.public static final <T> T[] slice(T[] values, int[] indices, Class<? extends T> clazz)
T
- the component type.values
- the values.indices
- the slice indices.clazz
- the component class.public static final Double[] box(double[] values)
double
s.values
- the values.public static final Integer[] box(int[] values)
int
s.values
- the values.public static final double[] unbox(Double[] values)
Double
s.values
- the values.public static final int[] unbox(Integer[] values)
Integer
s.values
- the values.public static final <T> T[] wrap(Class<T> clazz, T value, T... values)
T
- the component type.value
- the head value.values
- the trailing values.public static final <T> T[] wrap(T value, T... values)
wrap(Class, Object, Object...)
.public static final int compare(double[] lhs, double[] rhs)
double
s on the basis of lexicographic order.lhs
- the left hand side.rhs
- the right hand side.public static final int compare(int[] lhs, int[] rhs)
int
s on the basis of lexicographic order.lhs
- the left hand side.rhs
- the right hand side.public static final <T extends Comparable<? super T>> int compare(T[] lhs, T[] rhs)
T
- the component type.lhs
- the left hand side.rhs
- the right hand side.public static final <T> int compare(T[] lhs, T[] rhs, Comparator<? super T> c)
T
- the component type.lhs
- the left hand side.rhs
- the right hand side.c
- the Comparator
to use.public static final int binarySearchNearest(int[] values, int from, int to, int key, RoundingMode rm)
Arrays.binarySearch(int[], int, int, int)
that finds the array index with value
nearest to the given key, as determined by the provided RoundingMode
.values
- the values.from
- the search start index.to
- the search end index.key
- the key.rm
- the RoundingMode
.public static final int binarySearchNearest(int[] values, int to, int from, int key)
binarySearchNearest(int[], int, int, int, RoundingMode)
.public static final int binarySearchNearest(int[] values, int key, RoundingMode rm)
binarySearchNearest(int[], int, int, int, RoundingMode)
.public static final int binarySearchNearest(int[] values, int key)
binarySearchNearest(int[], int, int, int, RoundingMode)
.public static final int binarySearchNearest(double[] values, int from, int to, double key, RoundingMode rm)
Arrays.binarySearch(double[], int, int, double)
that finds the array index with
value nearest to the given key, as determined by the provided RoundingMode
.values
- the values.from
- the search start index.to
- the search end index.key
- the key.rm
- the RoundingMode
.public static final int binarySearchNearest(double[] values, int to, int from, double key)
public static final int binarySearchNearest(double[] values, double key, RoundingMode rm)
public static final int binarySearchNearest(double[] values, double key)
public static final <T extends Comparable<? super T>> int binarySearchNearest(T[] values, int from, int to, T key, RoundingMode rm)
Arrays.binarySearch(Object[], int, int, Object)
that finds the array index with
value nearest to the given key, as determined by the provided RoundingMode
.T
- the component type.values
- the values.from
- the search start index.to
- the search end index.key
- the key.rm
- the RoundingMode
.public static final <T extends Comparable<? super T>> int binarySearchNearest(T[] values, int to, int from, T key)
T
- the component type.public static final <T extends Comparable<? super T>> int binarySearchNearest(T[] values, T key, RoundingMode rm)
T
- the component type.public static final <T extends Comparable<? super T>> int binarySearchNearest(T[] values, T key)
T
- the component type.public static final <T> int binarySearchNearest(T[] values, T key, Comparator<? super T> c, RoundingMode rm)
Arrays.binarySearch(Object[], Object, Comparator)
that finds the array index with
value nearest to the given key, as determined by the provided RoundingMode
.T
- the component type.values
- the values.key
- the key.rm
- the RoundingMode
.c
- the Comparator
to use.public static final <T> int binarySearchNearest(T[] values, T key, Comparator<? super T> c)
binarySearchNearest(Object[], Object, Comparator)
.T
- the component type.public static final <T extends Comparable<? super T>> int binarySearchNearest(List<? extends T> values, T key, RoundingMode rm)
Collections.binarySearch(List, Object)
that finds the array index with value nearest to the
given key, as determined by the provided RoundingMode
.T
- the component type.values
- the values.key
- the key.rm
- the RoundingMode
.public static final <T extends Comparable<? super T>> int binarySearchNearest(List<? extends T> values, T key)
binarySearchNearest(List, Comparable, RoundingMode)
.T
- the component type.public static final <T> int binarySearchNearest(List<? extends T> values, T key, Comparator<? super T> c, RoundingMode rm)
Collections.binarySearch(List, Object, Comparator)
that finds the array index with value
nearest to the given key, as determined by the provided RoundingMode
.T
- the component type.values
- the values.key
- the key.rm
- the RoundingMode
.c
- the Comparator
to use.public static final <T> int binarySearchNearest(List<? extends T> values, T key, Comparator<? super T> c)
T
- the component type.