Package it.unimi.dsi.compression
Class CodeWordCoder
- java.lang.Object
-
- it.unimi.dsi.compression.CodeWordCoder
-
- All Implemented Interfaces:
Coder,PrefixCoder,java.io.Serializable
- Direct Known Subclasses:
Fast64CodeWordCoder
public class CodeWordCoder extends java.lang.Object implements PrefixCoder, java.io.Serializable
A coder based on a set of codewords.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CodeWordCoder(BitVector[] codeWord)Creates a new codeword-based coder using the given vector of codewords.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BitVector[]codeWords()Provides access to the codewords.it.unimi.dsi.fastutil.booleans.BooleanIteratorencode(int symbol)Encodes a symbol.intencode(int symbol, OutputBitStream obs)Encodes a symbol.it.unimi.dsi.fastutil.booleans.BooleanIteratorflush()Flushes the coder.intflush(OutputBitStream unused)Flushes the coder.
-
-
-
Field Detail
-
codeWord
protected final BitVector[] codeWord
The array of codewords of this coder.
-
-
Constructor Detail
-
CodeWordCoder
public CodeWordCoder(BitVector[] codeWord)
Creates a new codeword-based coder using the given vector of codewords. The coder will be able to encode symbols numbered from 0 tocodeWord.length-1, included.- Parameters:
codeWord- a vector of codewords.
-
-
Method Detail
-
encode
public it.unimi.dsi.fastutil.booleans.BooleanIterator encode(int symbol)
Description copied from interface:CoderEncodes a symbol.
-
encode
public int encode(int symbol, OutputBitStream obs) throws java.io.IOExceptionDescription copied from interface:CoderEncodes a symbol.
-
flush
public int flush(OutputBitStream unused)
Description copied from interface:CoderFlushes the coder. Warning: this method will notflushobs.
-
flush
public it.unimi.dsi.fastutil.booleans.BooleanIterator flush()
Description copied from interface:CoderFlushes the coder.
-
codeWords
public BitVector[] codeWords()
Description copied from interface:PrefixCoderProvides access to the codewords. Warning: bit 0 of each bit vector returned byPrefixCoder.codeWords()is the first (leftmost) bit of the corresponding codeword: in other words, codewords are stored in right-to-left fashion.- Specified by:
codeWordsin interfacePrefixCoder- Returns:
- the codewords.
-
-