Package it.unimi.dsi.compression
Class TreeDecoder
- java.lang.Object
-
- it.unimi.dsi.compression.TreeDecoder
-
- All Implemented Interfaces:
Decoder
,java.io.Serializable
public final class TreeDecoder extends java.lang.Object implements Decoder, java.io.Serializable
A decoder that follows 0/1 labelled paths in a tree.Additional, the
buildCodes()
method returns a vector of codewords corresponding to the paths of an instance of this class. Conversely, the codeword-based constructor builds a tree out of the codewords generated by root-to-leaf paths.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TreeDecoder.LeafNode
A leaf node of the decoding tree.static class
TreeDecoder.Node
A internal node of the decoding tree.
-
Constructor Summary
Constructors Constructor Description TreeDecoder(BitVector[] lexSortedCodeWord, int[] symbol)
Creates a new codeword-based decoder starting from a set of complete, lexicographically ordered codewords.TreeDecoder(TreeDecoder.Node root, int n)
Creates a new codeword-based decoder using the given tree.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BitVector[]
buildCodes()
Generate the codewords corresponding to this tree decoder.int
decode(it.unimi.dsi.fastutil.booleans.BooleanIterator iterator)
Decodes the next symbol from the given boolean iterator.int
decode(InputBitStream ibs)
Decodes the next symbol from the given input bit stream.LongArrayBitVector
succinctRepresentation()
-
-
-
Constructor Detail
-
TreeDecoder
public TreeDecoder(TreeDecoder.Node root, int n)
Creates a new codeword-based decoder using the given tree. It is responsibility of the caller that the tree is well-formed, that is, that all internal nodes are instances ofTreeDecoder.Node
and all leaf nodes are instances ofTreeDecoder.LeafNode
.- Parameters:
root
- the root of a decoding tree.n
- the number of leaves (symbols).
-
TreeDecoder
public TreeDecoder(BitVector[] lexSortedCodeWord, int[] symbol)
Creates a new codeword-based decoder starting from a set of complete, lexicographically ordered codewords. It is responsibility of the caller that the tree is well-formed, that is, that the provided codewords are exactly the root-to-leaf paths of such a tree.- Parameters:
lexSortedCodeWord
- a vector of lexically sorted codeWords.symbol
- a mapping from codewords to symbols.
-
-
Method Detail
-
decode
public int decode(it.unimi.dsi.fastutil.booleans.BooleanIterator iterator)
Description copied from interface:Decoder
Decodes the next symbol from the given boolean iterator.Note that
InputBitStream
implementsBooleanIterator
.
-
decode
public int decode(InputBitStream ibs) throws java.io.IOException
Description copied from interface:Decoder
Decodes the next symbol from the given input bit stream.Note that
InputBitStream
implementsBooleanIterator
.
-
buildCodes
public BitVector[] buildCodes()
Generate the codewords corresponding to this tree decoder.- Returns:
- a vector of codewords for this decoder.
-
succinctRepresentation
public LongArrayBitVector succinctRepresentation()
-
-