com.alexkasko.unsafe.offheapstruct
public class OffHeapStructBinarySearch extends Object
https://android.googlesource.com/platform/libcore/+/android-4.2.2_r1/luni/src/main/java/java/util/Arrays.java
and adapted to OffHeapStructCollection
OffHeapLongSorter
,
OffHeapStructSorter
Modifier and Type | Class and Description |
---|---|
static class |
OffHeapStructBinarySearch.IndexRange
OffHeapStructCollection index range representation. |
Constructor and Description |
---|
OffHeapStructBinarySearch() |
Modifier and Type | Method and Description |
---|---|
static long |
binarySearchByIntKey(OffHeapStructCollection collection,
long value,
int keyOffset)
Performs a binary search for
value in the ascending sorted off-heap struct collection using int struct key. |
static long |
binarySearchByIntKey(OffHeapStructCollection collection,
long startIndex,
long endIndex,
long value,
int keyOffset)
Performs a binary search for
value in the ascending sorted off-heap struct collection using int struct key. |
static long |
binarySearchByLongKey(OffHeapStructCollection collection,
long value,
int keyOffset)
Performs a binary search for
value in the ascending sorted off-heap struct collection using long struct key. |
static long |
binarySearchByLongKey(OffHeapStructCollection collection,
long startIndex,
long endIndex,
long value,
int keyOffset)
Performs a binary search for
value in the ascending sorted off-heap struct collection using long struct key. |
static void |
binarySearchRangeByIntKey(OffHeapStructCollection collection,
long value,
int keyOffset,
OffHeapStructBinarySearch.IndexRange out)
Performs a binary search for
value in the ascending sorted off-heap struct collection using int struct key. |
static void |
binarySearchRangeByIntKey(OffHeapStructCollection collection,
long startIndex,
long endIndex,
long value,
int keyOffset,
OffHeapStructBinarySearch.IndexRange out)
Performs a binary search for
value in the ascending sorted off-heap struct collection using int struct key. |
static void |
binarySearchRangeByLongKey(OffHeapStructCollection collection,
long value,
int keyOffset,
OffHeapStructBinarySearch.IndexRange out)
Performs a binary search for
value in the ascending sorted off-heap struct collection using long struct key. |
static void |
binarySearchRangeByLongKey(OffHeapStructCollection collection,
long startIndex,
long endIndex,
long value,
int keyOffset,
OffHeapStructBinarySearch.IndexRange out)
Performs a binary search for
value in the ascending sorted off-heap struct collection using long struct key. |
public OffHeapStructBinarySearch()
public static long binarySearchByLongKey(OffHeapStructCollection collection, long value, int keyOffset)
value
in the ascending sorted off-heap struct collection using long struct key.
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.keyOffset
- long key field offset within stuct bounds-index - 1
where the element would be inserted.public static long binarySearchByLongKey(OffHeapStructCollection collection, long startIndex, long endIndex, long value, int keyOffset)
value
in the ascending sorted off-heap struct collection using long struct key.
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.keyOffset
- long key field offset within stuct bounds-index - 1
where the element would be inserted.IllegalArgumentException
- if (startIndex < 0 || startIndex > endIndex || endIndex > collection.size()
public static void binarySearchRangeByLongKey(OffHeapStructCollection collection, long value, int keyOffset, OffHeapStructBinarySearch.IndexRange out)
value
in the ascending sorted off-heap struct collection using long struct key.
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.keyOffset
- long key field offset within stuct boundsout
- range instance, will be set with start/end indices having given value or with empty valuepublic static void binarySearchRangeByLongKey(OffHeapStructCollection collection, long startIndex, long endIndex, long value, int keyOffset, OffHeapStructBinarySearch.IndexRange out)
value
in the ascending sorted off-heap struct collection using long struct key.
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.keyOffset
- long key field offset within stuct boundsout
- range instance, will be set with start/end indices having given value or with empty valuepublic static long binarySearchByIntKey(OffHeapStructCollection collection, long value, int keyOffset)
value
in the ascending sorted off-heap struct collection using int struct key.
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.keyOffset
- int key field offset within stuct bounds-index - 1
where the element would be inserted.public static long binarySearchByIntKey(OffHeapStructCollection collection, long startIndex, long endIndex, long value, int keyOffset)
value
in the ascending sorted off-heap struct collection using int struct key.
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.keyOffset
- int key field offset within stuct bounds-index - 1
where the element would be inserted.IllegalArgumentException
- if (startIndex < 0 || startIndex > endIndex || endIndex > collection.size()
public static void binarySearchRangeByIntKey(OffHeapStructCollection collection, long value, int keyOffset, OffHeapStructBinarySearch.IndexRange out)
value
in the ascending sorted off-heap struct collection using int struct key.
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.keyOffset
- int key field offset within stuct boundsout
- range instance, will be set with start/end indices having given value or with empty valuepublic static void binarySearchRangeByIntKey(OffHeapStructCollection collection, long startIndex, long endIndex, long value, int keyOffset, OffHeapStructBinarySearch.IndexRange out)
value
in the ascending sorted off-heap struct collection using int struct key.
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.keyOffset
- int key field offset within stuct boundsout
- range instance, will be set with start/end indices having given value or with empty valueCopyright © 2014. All Rights Reserved.