|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.compression.HuTuckerCodec
public class HuTuckerCodec
An implementation of the Hu–Tucker optimal lexicographical prefix-free code.
The familiar Huffman coding technique can be extended so to preserve the order in which symbols are given to the coder, in the sense that if j<k, then the j-th symbol will get a code lexicographically smaller than the one assigned to the k-th symbol. This result can be obtained with a small loss in code length (for more details, see the third volume of The Art of Computer Programming).
A Hu–Tucker coder is built given an array of frequencies corresponding to each symbol. Frequency 0 symbols are allowed, but they will degrade the resulting code.
The implementation of this class is rather inefficient, and the time required to build a Hu–Tucker code is quadratic in the number of symbols. An O(n log n) implementation is possible, but it requires very sophisticated data structures.
Field Summary | |
---|---|
int |
size
The number of symbols of this coder. |
Constructor Summary | |
---|---|
HuTuckerCodec(int[] frequency)
|
|
HuTuckerCodec(long[] frequency)
|
Method Summary | |
---|---|
CodeWordCoder |
coder()
Returns a coder for the compression technique represented by this coded. |
BitVector[] |
codeWords()
Returns the vector of prefix-free codewords used by this prefix coder. |
Decoder |
decoder()
Returns a decoder for the compression technique represented by this coded. |
PrefixCoder |
getCoder()
Deprecated. |
Decoder |
getDecoder()
Deprecated. |
int |
size()
Returns the number of symbols handled by this codec. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int size
Constructor Detail |
---|
public HuTuckerCodec(int[] frequency)
public HuTuckerCodec(long[] frequency)
Method Detail |
---|
public CodeWordCoder coder()
Codec
coder
in interface Codec
coder
in interface PrefixCodec
public Decoder decoder()
Codec
decoder
in interface Codec
public int size()
Codec
size
in interface Codec
public BitVector[] codeWords()
PrefixCodec
codeWords
in interface PrefixCodec
@Deprecated public PrefixCoder getCoder()
@Deprecated public Decoder getDecoder()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |