List of utility methods to do ByteBuffer Search
int | binarySearch(ByteBuffer[] cells, ByteBuffer key, Comparator Binary searches for the specified key, assuming the cells are sorted in ascending order. return Arrays.binarySearch(cells, key, order);
|
int | indexOf(ByteBuffer buf, byte b) index Of for (int i = 0; i < buf.remaining(); i++) { if (buf.get(buf.position() + i) == b) { return i; return -1; |
int | indexOf(ByteBuffer buf, byte value) index Of if (buf.hasArray()) { byte[] array = buf.array(); int begin = buf.arrayOffset() + buf.position(); int end = buf.arrayOffset() + buf.limit(); for (int offset = 0; offset < end && offset > -1; ++offset) { if (array[begin + offset] == value) { return offset; } else { int begin = buf.position(); for (int offset = 0; offset < buf.limit(); ++offset) { if (buf.get(begin + offset) == value) { return offset; return -1; |
int | indexOf(ByteBuffer buffer, byte b) index Of return indexOf(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining(), b);
|
int | indexOf(ByteBuffer buffer, ByteBuffer pattern) index Of if (pattern == null || buffer == null) { return -1; int n = buffer.remaining(); int m = pattern.remaining(); int patternPos = pattern.position(); int bufferPos = buffer.position(); if (n < m) { ... |
int | indexOf(ByteBuffer buffer, ByteBuffer pattern) Returns the index within this buffer of the first occurrence of the specified pattern buffer. int patternPos = pattern.position(); int patternLen = pattern.remaining(); int lastIndex = buffer.limit() - patternLen + 1; Label: for (int i = buffer.position(); i < lastIndex; i++) { for (int j = 0; j < patternLen; j++) { if (buffer.get(i + j) != pattern.get(patternPos + j)) continue Label; return i; return -1; |
int | indexOf(final ByteBuffer buf, final int c, final int start, final int end) Returns the index of the given char within the given ByteBuffer . final int cc = c; final ByteBuffer bb = buf; int pos = start, rem = end - start; while (rem-- != 0) { if (bb.get(pos) == cc) return pos; ++pos; return -1; |
int | indexOf(final ByteBuffer haystack, byte[] needle) index Of return indexOf(haystack, haystack.position(), haystack.limit(), needle);
|
ByteBuffer | search(ByteBuffer buffer, int n, byte[] param) search ByteBuffer result = buffer.duplicate(); int step = 0, rem = buffer.position(); while (buffer.hasRemaining()) { int b = buffer.get(); if (b == param[step]) { ++step; if (step == param.length) { if (n == 0) { ... |
int | unsignedBinarySearch(final ByteBuffer array, int position, final int begin, final int end, final short k) Look for value k in buffer in the range [begin,end). return branchyUnsignedBinarySearch(array, position, begin, end, k);
|