public class EncodedElement
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
offset
Used to signify the index of the first valid bit of the data array.
|
Constructor and Description |
---|
EncodedElement()
Constructor, creates an empty element with offset of zero and array size
of 100.
|
EncodedElement(byte[] array,
int off)
Constructor.
|
EncodedElement(byte[] array,
int off,
int usedBits) |
EncodedElement(int size,
int off)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
addInt_new(int value,
int count,
int startPos,
byte[] dest)
This method adds a given number of bits of an int to a byte array.
|
EncodedElement |
addInt(int input,
int bitCount)
Add a number of bits from an int to the end of this list's data.
|
EncodedElement |
addLong(long input,
int bitCount)
Add a number of bits from a long to the end of this list's data.
|
boolean |
attachEnd(EncodedElement e)
Attach an element to the end of this list.
|
protected static int |
cleanInts(int[] input,
int[] inputBits,
int inputIndex,
int count) |
void |
clear(int size,
int off)
Completely clear this element and use the given size and offset for the
new data array.
|
void |
clear(int size,
int off,
boolean keep)
Completely clear this element and use the given size and offset for the
new data array.
|
protected static int |
compressIntArrayByBits(int[] input,
int[] inputBits,
int inCount,
int inputIndex) |
short |
getCRC16() |
protected static EncodedElement |
getEnd_S(EncodedElement e)
Return the last element of the list given.
|
EncodedElement |
getEnd()
Return the last element of the list given.
|
int |
getTotalBits()
Total number of usable bits stored by this entire list.
|
protected static void |
mergeFullOnByte(int[] input,
int inCount,
byte[] dest,
int destIndex) |
EncodedElement |
packInt(int[] inputArray,
int bitSize,
int start,
int skip,
int countA)
Append an equal number of bits from each int in an array within given
limits to the end of this list.
|
EncodedElement |
packIntByBits(int[] inputA,
int[] inputBits,
int inputOffset,
int countA)
Pack a number of bits from each int of an array(within given limits)to
the end of this list.
|
protected static void |
packIntByBits(int[] inputA,
int[] inputBits,
int inputIndex,
int inputCount,
int destPos,
byte[] dest)
Pack a number of bits from each int of an array(within given limits)to
the end of this list.
|
protected static int |
packIntByBitsToByteBoundary(int[] input,
int[] inputBits,
int inputIndex,
int inputCount,
int destPos,
byte[] dest) |
boolean |
padToByte()
Force the usable data stored in this list ends on a a byte boundary, by
padding to the end with zeros.
|
protected void |
print() |
protected void |
print(int childCount) |
protected int offset
public EncodedElement()
public EncodedElement(byte[] array, int off)
array
- Byte array to use for this element.off
- Offset to use for this element. Usablebits will also be set
to this value.public EncodedElement(byte[] array, int off, int usedBits)
public EncodedElement(int size, int off)
size
- Size of data array to use(in bytes)off
- Offset to use for this element. Usablebits will also be set
to this value.public void clear(int size, int off)
size
- Size of data array to use(in bytes)off
- Offset to use for this element. Usablebits will also be set to
this value.public void clear(int size, int off, boolean keep)
size
- Size of data array to use(in bytes)off
- Offset to use for this element. Usablebits will also be set to
this value.keep
- true to keep current backing array, false to create new one.protected static EncodedElement getEnd_S(EncodedElement e)
e
- EncodedElement list to find end of.public EncodedElement getEnd()
public boolean attachEnd(EncodedElement e)
e
- Element to attach.public EncodedElement addLong(long input, int bitCount)
input
- Long containing bits to append to end.bitCount
- Number of bits to append.public EncodedElement addInt(int input, int bitCount)
input
- Int containing bits to append to end.bitCount
- Number of bits to append.public EncodedElement packInt(int[] inputArray, int bitSize, int start, int skip, int countA)
inputArray
- Array storing input values.bitSize
- number of bits to store from each value.start
- index of first usable index.skip
- number of indices to skip between values(in case input data
is interleaved with non-desirable data).countA
- Number of total indices to store from.public EncodedElement packIntByBits(int[] inputA, int[] inputBits, int inputOffset, int countA)
inputA
- Array containing input values.inputBits
- Array containing number of bits to use for each index
packed. This array should be equal in size to the inputA array.inputOffset
- Index of first usable index.countA
- Number of indices to pack.public int getTotalBits()
protected static void addInt_new(int value, int count, int startPos, byte[] dest)
value
- int to store bits fromcount
- number of low-order bits to storestartPos
- start bit location in array to begin writingdest
- array to store bits in. dest MUST have enough space to store
the given data, or this function will fail.public boolean padToByte()
public short getCRC16()
protected void print()
protected void print(int childCount)
protected static int packIntByBitsToByteBoundary(int[] input, int[] inputBits, int inputIndex, int inputCount, int destPos, byte[] dest)
protected static void packIntByBits(int[] inputA, int[] inputBits, int inputIndex, int inputCount, int destPos, byte[] dest)
inputA
- Array containing input values.inputBits
- Array containing number of bits to use for each index
packed. This array should be equal in size to the inputA array.inputOffset
- Index of first usable index.countA
- Number of indices to pack.startPosIn
- First usable bit-level index in destination array(byte
index = startPosIn/8, bit within that byte = startPosIn%8)dest
- Destination array to store input values in. This array *must*
be large enough to store all values or this method will fail in an
undefined manner.protected static int cleanInts(int[] input, int[] inputBits, int inputIndex, int count)
protected static int compressIntArrayByBits(int[] input, int[] inputBits, int inCount, int inputIndex)
protected static void mergeFullOnByte(int[] input, int inCount, byte[] dest, int destIndex)