Package io.deephaven.function
Class BinSearch
java.lang.Object
io.deephaven.function.BinSearch
Functions for performing binary searches.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
binSearchIndex
(byte[] values, byte key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(char[] values, char key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(double[] values, double key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(float[] values, float key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(int[] values, int key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(long[] values, long key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(short[] values, short key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(ByteVector values, byte key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(CharVector values, char key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(DoubleVector values, double key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(FloatVector values, float key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(IntVector values, int key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(LongVector values, long key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static <T extends Comparable<? super T>>
intbinSearchIndex
(ObjectVector<T> values, T key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
binSearchIndex
(ShortVector values, short key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static <T extends Comparable<? super T>>
intbinSearchIndex
(T[] values, T key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(byte[] values, byte key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(char[] values, char key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(double[] values, double key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(float[] values, float key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(int[] values, int key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(long[] values, long key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(short[] values, short key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(ByteVector values, byte key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(CharVector values, char key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(DoubleVector values, double key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(FloatVector values, float key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(IntVector values, int key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(LongVector values, long key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static <T extends Comparable<? super T>>
intrawBinSearchIndex
(ObjectVector<T> values, T key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static int
rawBinSearchIndex
(ShortVector values, short key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.static <T extends Comparable<? super T>>
intrawBinSearchIndex
(T[] values, T key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.
-
Constructor Details
-
BinSearch
public BinSearch()
-
-
Method Details
-
binSearchIndex
public static <T extends Comparable<? super T>> int binSearchIndex(T[] values, T key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index of where the key would be inserted.
-
binSearchIndex
public static <T extends Comparable<? super T>> int binSearchIndex(ObjectVector<T> values, T key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index of where the key would be inserted.
-
rawBinSearchIndex
public static <T extends Comparable<? super T>> int rawBinSearchIndex(T[] values, T key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
rawBinSearchIndex
public static <T extends Comparable<? super T>> int rawBinSearchIndex(ObjectVector<T> values, T key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index immediately before where the key would be inserted.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index of where the key would be inserted.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index immediately before where the key would be inserted.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index of where the key would be inserted.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index immediately before where the key would be inserted.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index of where the key would be inserted.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index immediately before where the key would be inserted.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index of where the key would be inserted.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index immediately before where the key would be inserted.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index of where the key would be inserted.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index immediately before where the key would be inserted.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index of where the key would be inserted.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index immediately before where the key would be inserted.
-
binSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise, the index of where the key would be inserted.
-
rawBinSearchIndex
Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-
rawBinSearchIndex
public static int rawBinSearchIndex(DoubleVector values, double key, BinSearchAlgo choiceWhenEquals) Performs a binary search to find a key.- Parameters:
values
- sorted values to search. Null values are not supported.key
- key to search for. Null keys are not supported.choiceWhenEquals
- algorithm used to resolve ties when performing a binary search.- Returns:
- index of the search key, if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
-