|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.at4j.support.comp.IntMoveToFront
public class IntMoveToFront
A move-to-front (MTF) encoder and decoder for integers. For more information on MTF encoding, seethe Wikipedia article on move-to-front transforms.
This object is not thread safe. Clients must provide external synchronization if they are to use it from several concurrent threads.
ByteMoveToFront| Constructor Summary | |
|---|---|
IntMoveToFront(int[] alphabet)
Create a byte MTF encoder/decoder that transforms integers using the supplied initial alphabet. |
|
IntMoveToFront(int minValue,
int maxValue)
Create a byte MTF encoder/decoder that transforms integers in the range between minValue and maxValue. |
|
| Method Summary | |
|---|---|
int |
decode(int index)
Decode a single integer and update the MTF alphabet. |
int[] |
decode(int[] in,
int[] out)
Decode an array of integers and update the MTF alphabet. |
int[] |
encode(int[] in,
int[] out)
Encode the integers in in and store them in the array out
. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IntMoveToFront(int minValue,
int maxValue)
throws IndexOutOfBoundsException
minValue and maxValue.
The initial alphabet of the transformer will be minValue …
maxValue.
minValue - The start value of the range.maxValue - The end value of the range.
IndexOutOfBoundsException - If the min value is equal to or greater
than the max value.public IntMoveToFront(int[] alphabet)
alphabet - The initial alphabet. This integer array is not
copied by this method and it will be modified by encoding or decoding
operations.| Method Detail |
|---|
public int[] encode(int[] in,
int[] out)
throws ArrayIndexOutOfBoundsException,
IllegalArgumentException
in and store them in the array out
. The MTF alphabet is also updated by this method.
in - The integers to encode.out - The array to store the encoded integers in. This array must be
at least as long as in.
out
ArrayIndexOutOfBoundsException - If any of the integers in in are not in the MTF alphabet.
IllegalArgumentException - If the out array is too short.public int decode(int index)
index - The index in the MTF alphabet for the integer.
public int[] decode(int[] in,
int[] out)
throws ArrayIndexOutOfBoundsException,
IllegalArgumentException
out.
in - The integers to decode.out - The array to store the decoded integers in. This array must be
at least as long as in.
out
ArrayIndexOutOfBoundsException - If any of the integers in in are not in the MTF alphabet.
IllegalArgumentException - If out is too short.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||