com.alexkasko.unsafe.offheaplong
public class OffHeapLongBinarySearch extends Object
https://android.googlesource.com/platform/libcore/+/android-4.2.2_r1/luni/src/main/java/java/util/Arrays.java
and adapted to OffHeapAddressable
OffHeapLongSorter
Modifier and Type | Class and Description |
---|---|
static class |
OffHeapLongBinarySearch.IndexRange
OffHeapAddressable index range representation. |
Constructor and Description |
---|
OffHeapLongBinarySearch() |
Modifier and Type | Method and Description |
---|---|
static long |
binarySearch(OffHeapAddressable collection,
long value)
Performs a binary search for
value in the ascending sorted off-heap collection. |
static long |
binarySearch(OffHeapAddressable collection,
long startIndex,
long endIndex,
long value)
Performs a binary search for
value in the ascending sorted off-heap collection,
in the range specified by fromIndex (inclusive) and toIndex (exclusive). |
static void |
binarySearchRange(OffHeapAddressable collection,
long startIndex,
long endIndex,
long value,
OffHeapLongBinarySearch.IndexRange out)
Performs a binary search for
value in the ascending sorted off-heap collection. |
static void |
binarySearchRange(OffHeapAddressable collection,
long value,
OffHeapLongBinarySearch.IndexRange out)
Performs a binary search for
value in the ascending sorted off-heap collection. |
public OffHeapLongBinarySearch()
public static long binarySearch(OffHeapAddressable collection, long value)
value
in the ascending sorted off-heap collection.
Searching in an unsorted collection has an undefined result. It's also undefined which element
is found if there are multiple occurrences of the same element.collection
- the sorted array to search.value
- the element to find.-index - 1
where the element would be inserted.public static long binarySearch(OffHeapAddressable collection, long startIndex, long endIndex, long value)
value
in the ascending sorted off-heap collection,
in the range specified by fromIndex (inclusive) and toIndex (exclusive).
Searching in an unsorted collection has an undefined result. It's also undefined which element
is found if there are multiple occurrences of the same element.collection
- the sorted collection to search.startIndex
- the inclusive start index.endIndex
- the exclusive end index.value
- the element to find.-index - 1
where the element would be inserted.IllegalArgumentException
- if (startIndex < 0 || startIndex > endIndex || endIndex > collection.size()
public static void binarySearchRange(OffHeapAddressable collection, long value, OffHeapLongBinarySearch.IndexRange out)
value
in the ascending sorted off-heap collection.
Returns range of indices having given value or empty range.
Searching in an unsorted collection has an undefined result. It's also undefined which element
is found if there are multiple occurrences of the same element.collection
- the sorted array to search.value
- the element to find.out
- range instance, will be set with start/end indices having given value or with empty valuepublic static void binarySearchRange(OffHeapAddressable collection, long startIndex, long endIndex, long value, OffHeapLongBinarySearch.IndexRange out)
value
in the ascending sorted off-heap collection.
Returns range of indices having given value or empty range.
Searching in an unsorted collection has an undefined result. It's also undefined which element
is found if there are multiple occurrences of the same element.collection
- the sorted array to search.startIndex
- the inclusive start index.endIndex
- the exclusive end index.value
- the element to find.out
- range instance, will be set with start/end indices having given value or with empty valueCopyright © 2014. All Rights Reserved.