T- The type of the serialized form.
public final class KeyCompressor<T> extends Object
T[this.size()]is more straightforward, but incurs linear run time for compression.
|Constructor and Description|
Constructs a new key compressor for the given key stream.
|Modifier and Type||Method and Description|
Returns the key index associated with the key the given string represents.
Returns the key index associated with the given key.
Returns the key associated with the given key index, or
The size of the key set represented by this key compressor.
public KeyCompressor(DynamicOps<T> ops, Stream<T> keyStream)
The key stream is consumed in the constructor. It should be finite, or else this constructor will run forever.
DynamicOpsinstance defining the serialized form.
keyStream- A stream of keys this key compressor compresses.
public T decompress(int key)
nullif the key index does not correspond to a key.
Caution: This is one of the few methods in DFU that may return
key- The key index.
nullif the key index is invalid.
public int compress(String key)
key- The string representation of a key.
-1if the key does not exist.
public int compress(T key)
key- The key.
-1if the key is invalid.
public int size()