public class IntMoveToFront extends Object
This object is not thread safe. Clients must provide external synchronization if they are to use it from several concurrent threads.
ByteMoveToFront| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
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
. |
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.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.outArrayIndexOutOfBoundsException - 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.outArrayIndexOutOfBoundsException - If any of the integers in in are not in the MTF alphabet.IllegalArgumentException - If out is too short.