- All Implemented Interfaces:
Serializable,Comparable<BufferSearch>,Constable
java.util.Arrays, modified with minimal changes to support nio
buffers.
Also provides methods for finding the first or last index of a sequence of duplicate values.
- Author:
- biteytech@protonmail.com, adapted from java.util.Arrays
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Method Summary
Modifier and TypeMethodDescriptionstatic intbinaryFindFirst(ByteBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedByteBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(DoubleBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedDoubleBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(FloatBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedFloatBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(IntBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedIntBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(LongBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedLongBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(ShortBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedShortBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(SmallByteBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedSmallByteBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(SmallDoubleBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedSmallDoubleBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(SmallFloatBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedSmallFloatBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(SmallIntBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedSmallIntBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(SmallLongBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedSmallLongBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindFirst(SmallShortBuffer b, int minIndex, int keyIndex) Searches a range of the specifiedSmallShortBufferfor the first occurrence of the value at the givenkeyIndex.static intbinaryFindLast(ByteBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedByteBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(DoubleBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedDoubleBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(FloatBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedFloatBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(IntBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedIntBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(LongBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedLongBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(ShortBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedShortBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(SmallByteBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedSmallByteBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(SmallDoubleBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedSmallDoubleBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(SmallFloatBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedSmallFloatBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(SmallIntBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedSmallIntBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(SmallLongBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedSmallLongBufferfor the last occurrence of the value at the givenkeyIndex.static intbinaryFindLast(SmallShortBuffer b, int maxIndex, int keyIndex) Searches a range of the specifiedSmallShortBufferfor the last occurrence of the value at the givenkeyIndex.static intbinarySearch(ByteBuffer b, int fromIndex, int toIndex, byte key) Searches a range of the specifiedByteBufferfor the specified value using the binary search algorithm.static intbinarySearch(DoubleBuffer b, int fromIndex, int toIndex, double key) Searches a range of the specifiedDoubleBufferfor the specified value using the binary search algorithm.static intbinarySearch(FloatBuffer b, int fromIndex, int toIndex, float key) Searches a range of the specifiedFloatBufferfor the specified value using the binary search algorithm.static intbinarySearch(IntBuffer b, int fromIndex, int toIndex, int key) Searches a range of the specifiedIntBufferfor the specified value using the binary search algorithm.static intbinarySearch(LongBuffer b, int fromIndex, int toIndex, long key) Searches a range of the specifiedLongBufferfor the specified value using the binary search algorithm.static intbinarySearch(ShortBuffer b, int fromIndex, int toIndex, short key) Searches a range of the specifiedShortBufferfor the specified value using the binary search algorithm.static intbinarySearch(SmallByteBuffer b, int fromIndex, int toIndex, byte key) Searches a range of the specifiedSmallByteBufferfor the specified value using the binary search algorithm.static intbinarySearch(SmallDoubleBuffer b, int fromIndex, int toIndex, double key) Searches a range of the specifiedSmallDoubleBufferfor the specified value using the binary search algorithm.static intbinarySearch(SmallFloatBuffer b, int fromIndex, int toIndex, float key) Searches a range of the specifiedSmallFloatBufferfor the specified value using the binary search algorithm.static intbinarySearch(SmallIntBuffer b, int fromIndex, int toIndex, int key) Searches a range of the specifiedSmallIntBufferfor the specified value using the binary search algorithm.static intbinarySearch(SmallLongBuffer b, int fromIndex, int toIndex, long key) Searches a range of the specifiedSmallLongBufferfor the specified value using the binary search algorithm.static intbinarySearch(SmallShortBuffer b, int fromIndex, int toIndex, short key) Searches a range of the specifiedSmallShortBufferfor the specified value using the binary search algorithm.static BufferSearchReturns the enum constant of this class with the specified name.static BufferSearch[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
binarySearch
Searches a range of the specifiedIntBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedLongBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedShortBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedByteBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedFloatBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found. This method considers all NaN values to be equivalent and equal.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedDoubleBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found. This method considers all NaN values to be equivalent and equal.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedIntBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedIntBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedLongBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedLongBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedShortBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedShortBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedByteBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedByteBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedFloatBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. This method considers all NaN values to be equivalent and equal.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedFloatBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. This method considers all NaN values to be equivalent and equal.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedDoubleBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. This method considers all NaN values to be equivalent and equal.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedDoubleBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. This method considers all NaN values to be equivalent and equal.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedSmallIntBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedSmallLongBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedSmallShortBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedSmallByteBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedSmallFloatBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found. This method considers all NaN values to be equivalent and equal.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binarySearch
Searches a range of the specifiedSmallDoubleBufferfor the specified value using the binary search algorithm. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found. This method considers all NaN values to be equivalent and equal.- Parameters:
b- the buffer to be searchedfromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the buffer within the
specified range; otherwise,
(-(<i>insertion point</i>) - 1). The insertion point is defined as the point at which the key would be inserted into the buffer: the index of the first element in the range greater than the key, ortoIndexif all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexIndexOutOfBoundsException- iffromIndex < 0 or toIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedSmallIntBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedSmallIntBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedSmallLongBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedSmallLongBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedSmallShortBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedSmallShortBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedSmallByteBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedSmallByteBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedSmallFloatBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. This method considers all NaN values to be equivalent and equal.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedSmallFloatBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. This method considers all NaN values to be equivalent and equal.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-
binaryFindFirst
Searches a range of the specifiedSmallDoubleBufferfor the first occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. This method considers all NaN values to be equivalent and equal.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedminIndex- the lowest index to be searchedkeyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the first occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifminIndex > keyIndexIndexOutOfBoundsException- ifminIndex < 0 or keyIndex >= b.capacity()
-
binaryFindLast
Searches a range of the specifiedSmallDoubleBufferfor the last occurrence of the value at the givenkeyIndex. The range must be sorted in ascending order prior to making this call. If it is not sorted, the results are undefined. This method considers all NaN values to be equivalent and equal.This method is useful as a post-processing step after a binary search on a buffer which contains duplicate elements.
- Parameters:
b- the buffer to be searchedmaxIndex- the highest index to be searched (exclusive)keyIndex- an index of the value for which to find the first occurrence (inclusive)- Returns:
- index of the last occurrence of the value at
keyIndex - Throws:
IllegalArgumentException- ifmaxIndex < keyIndexIndexOutOfBoundsException- ifkeyIndex < 0 or maxIndex > b.capacity()
-