Package it.unimi.dsi.sux4j.mph.codec
Interface Codec.Decoder
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
Codec.Binary.Coder.Decoder
,Codec.Gamma.Coder.Decoder
,Codec.Huffman.Coder.Decoder
,Codec.Unary.Coder.Decoder
,Codec.ZeroCodec.Coder.Decoder
- Enclosing interface:
- Codec
public static interface Codec.Decoder extends java.io.Serializable
A decoder: provides a method to turn sequences of bits into symbols.Note that a decoder can only built using
Codec.Coder.getDecoder()
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description long
decode(long sequence)
Decodes a sequence of bits.default int
escapedSymbolLength()
Returns the length in bit of an escaped symbol, or zero if there are no escaped symbols.default int
escapeLength()
Returns the length of the escape codeword, if it exists, or zero.long
numBits()
The number of bits used by this decoder.
-
-
-
Method Detail
-
decode
long decode(long sequence)
Decodes a sequence of bits.If the first codeword appearing in the sequence is the escape codeword, this method returns −1 and the actual symbol must be retrieved by reading
escapedSymbolLength()
further bits.This method assumes that the first bit of the code is the leftmost bit (i.e., the bit of index
Codec.Coder.maxCodewordLength()
− 1).- Parameters:
sequence
- a sequence of bits.- Returns:
- the symbol associated with the first codeword appearing in the sequence, or −1 if the codeword is an escape.
-
numBits
long numBits()
The number of bits used by this decoder.- Returns:
- the number of bits used by this decoder.
-
escapedSymbolLength
default int escapedSymbolLength()
Returns the length in bit of an escaped symbol, or zero if there are no escaped symbols.- Returns:
- the length in bit of an escaped symbol, or zero if there are no escaped symbols.
-
escapeLength
default int escapeLength()
Returns the length of the escape codeword, if it exists, or zero.- Returns:
- the escape codeword, if it exists, or zero.
-
-