public final class BytesTrieBuilder extends StringTrieBuilder
This class is not intended for public subclassing.
StringTrieBuilder.Option| Constructor and Description |
|---|
BytesTrieBuilder()
Constructs an empty builder.
|
| Modifier and Type | Method and Description |
|---|---|
BytesTrieBuilder |
add(byte[] sequence,
int length,
int value)
Adds a (byte sequence, value) pair.
|
BytesTrie |
build(StringTrieBuilder.Option buildOption)
Builds a BytesTrie for the add()ed data.
|
ByteBuffer |
buildByteBuffer(StringTrieBuilder.Option buildOption)
Builds a BytesTrie for the add()ed data and byte-serializes it.
|
BytesTrieBuilder |
clear()
Removes all (byte sequence, value) pairs.
|
public BytesTrieBuilder add(byte[] sequence, int length, int value)
sequence - The array that contains the byte sequence, starting at index 0.length - The length of the byte sequence.value - The value associated with this byte sequence.public BytesTrie build(StringTrieBuilder.Option buildOption)
A BytesTrie cannot be empty. At least one (byte sequence, value) pair must have been add()ed.
Multiple calls to build() or buildByteBuffer() return tries or buffers which share the builder's byte array, without rebuilding. The byte array must not be modified via the buildByteBuffer() result object. After clear() has been called, a new array will be used.
buildOption - Build option, see StringTrieBuilder.Option.public ByteBuffer buildByteBuffer(StringTrieBuilder.Option buildOption)
A BytesTrie cannot be empty. At least one (byte sequence, value) pair must have been add()ed.
Multiple calls to build() or buildByteBuffer() return tries or buffers which share the builder's byte array, without rebuilding. Do not modify the bytes in the buffer! After clear() has been called, a new array will be used.
The serialized BytesTrie is accessible via the buffer's array()/arrayOffset()+position() or remaining()/get(byte[]) etc.
buildOption - Build option, see StringTrieBuilder.Option.public BytesTrieBuilder clear()