Package it.unimi.dsi.compression
Class CodeWordCoder
java.lang.Object
it.unimi.dsi.compression.CodeWordCoder
- All Implemented Interfaces:
Coder
,PrefixCoder
,Serializable
- Direct Known Subclasses:
Fast64CodeWordCoder
A coder based on a set of codewords.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCodeWordCoder
(BitVector[] codeWord) Creates a new codeword-based coder using the given vector of codewords. -
Method Summary
Modifier and TypeMethodDescriptionProvides access to the codewords.encode
(int symbol) Encodes a symbol.int
encode
(int symbol, OutputBitStream obs) Encodes a symbol.flush()
Flushes the coder.int
flush
(OutputBitStream unused) Flushes the coder.
-
Field Details
-
codeWord
The array of codewords of this coder.
-
-
Constructor Details
-
CodeWordCoder
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 Details
-
encode
Description copied from interface:Coder
Encodes a symbol. -
encode
Description copied from interface:Coder
Encodes a symbol.- Specified by:
encode
in interfaceCoder
- Parameters:
symbol
- a symbol.obs
- the output bit stream where the encoded symbol will be written.- Returns:
- the number of bits written.
- Throws:
IOException
-
flush
Description copied from interface:Coder
Flushes the coder. Warning: this method will notflush
obs
. -
flush
Description copied from interface:Coder
Flushes the coder. -
codeWords
Description copied from interface:PrefixCoder
Provides 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:
codeWords
in interfacePrefixCoder
- Returns:
- the codewords.
-