Description
Binary searches for the specified
key, assuming the
cells are sorted in ascending
order.
License
Apache License
Parameter
Parameter | Description |
---|
order | if <tt>null</tt>, then searched in lexical order |
Exception
Parameter | Description |
---|
NullPointerException | if <tt>key</tt>, <tt>cells</tt>, or any of its elements is <tt>null</tt> |
Declaration
public static int binarySearch(ByteBuffer[] cells, ByteBuffer key, Comparator<ByteBuffer> order)
Method Source Code
//package com.java2s;
//License from project: Apache License
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Comparator;
public class Main {
/**/* ww w . j a va2 s. co m*/
* Binary searches for the specified <tt>key</tt>, assuming the <tt>cells</tt> are sorted in
* ascending <tt>order</tt>. Results are undefined otherwise. If no matching cell is found,
* then the [negative] index returned has the same semantics as that specified in
* {@linkplain Arrays#binarySearch(Object[], Object, Comparator)}.
* <p/>
* This method behaves exactly as {@linkplain #binaryFirst(ByteBuffer, Comparator) binaryFirst} and
* {@linkplain #binaryLast(ByteBuffer, Comparator) binaryLast}, if there are no duplicate
* cells (except that its faster); if there are dups, and there is a hit on a dupe,
* then there is no guarantee which of the dups is chosen.
* <pre><tt>
public int binarySearch(ByteBuffer[] cells, ByteBuffer key, Comparator<ByteBuffer> order) {
return Arrays.binarySearch(cells, key, order);
}
* </tt></pre>
*
* @param order
* if <tt>null</tt>, then searched in lexical order
*
* @throws NullPointerException
* if <tt>key</tt>, <tt>cells</tt>, or any of its elements is <tt>null</tt>
*/
public static int binarySearch(ByteBuffer[] cells, ByteBuffer key, Comparator<ByteBuffer> order) {
return Arrays.binarySearch(cells, key, order);
}
}
Related
- indexOf(ByteBuffer buf, byte b)
- indexOf(ByteBuffer buf, byte value)
- indexOf(ByteBuffer buffer, byte b)
- indexOf(ByteBuffer buffer, ByteBuffer pattern)