Add keyAfter method to Java bindings
This commit is contained in:
parent
05ac4a38f8
commit
f788ba5f85
|
@ -359,6 +359,21 @@ public class ByteArrayUtil {
|
|||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the key that would sort immediately after {@code key}.
|
||||
* {@code key} must be non-null.
|
||||
*
|
||||
* @param key byte array for which next key is to be computed
|
||||
*
|
||||
* @return a newly created byte array that would sort immediately after {@code key}
|
||||
*/
|
||||
public static byte[] keyAfter(byte[] key) {
|
||||
byte[] copy = new byte[key.length + 1];
|
||||
System.arraycopy(key, 0, copy, 0, key.length);
|
||||
copy[key.length] = 0x0;
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of an array, with all matching characters stripped from trailing edge.
|
||||
* @param input array to copy. Must not be null.
|
||||
|
|
Loading…
Reference in New Issue