|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.foray.common.ByteVectorPacked
public class ByteVectorPacked
A vector of nibbles, or half bytes. The purpose of this class is to reduce by approximately half the amount of memory needed to store a data structure which only needs 4 bits for each element.
| Constructor Summary | |
|---|---|
ByteVectorPacked()
No-argument constructor. |
|
ByteVectorPacked(int capacity)
Constructor. |
|
| Method Summary | |
|---|---|
void |
add(byte value)
Adds one element to the vector. |
void |
add(byte[] value)
Adds the content of a byte array to this vector. |
int |
capacity()
Returns the current capacity of the vector, in half-bytes. |
int |
computeByteIndex(int nibbleIndex)
Converts an index specified for nibbles into the correct index to use to retrieve the byte containing that nibble. |
byte |
get(int index)
Retrieve a value from a specific index in the vector. |
int |
indexOf(byte value,
int startingIndex)
Returns the index of the first occurrence of a specified value in the vector. |
int |
length()
Returns the number of half-byte items in the vector. |
int |
lengthInBytes()
Returns the number of bytes actually used to store the vector content. |
void |
set(int index,
byte value)
Place an item in the vector at a specific index. |
void |
trimToSize()
Sets the capacity of this vector equal to its size, to that there is no unused capacity. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteVectorPacked()
public ByteVectorPacked(int capacity)
capacity - The initial capacity, in half-bytes, of the new vector.| Method Detail |
|---|
public int length()
public int lengthInBytes()
public int capacity()
public int computeByteIndex(int nibbleIndex)
nibbleIndex - The index to the nibble.
public void add(byte value)
value - The half-byte value to be added to the vector.
This must be in the range 0x0 thru 0xF.public void add(byte[] value)
value - The array of half-byte values to be added to the vector.
Each element must be in the range 0x0 thru 0xF.
public void set(int index,
byte value)
index - The 0-based index into the vector.value - The half-byte value to be placed in the vector. This must be in the range
0x0 thru 0xF.public byte get(int index)
index - The 0-based index whose value should be returned.
index.public void trimToSize()
public int indexOf(byte value,
int startingIndex)
value - The value whose index is sought.startingIndex - The index in the vector at which the search should be started.
value at or after startingIndex, or -1 if it does
not occur in the vector.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||