public class SuballocatedByteVector extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
m_blocksize
Size of blocks to allocate
|
protected int |
m_firstFree
Number of bytes in array
|
protected byte[][] |
m_map
Array of arrays of bytes
|
protected byte[] |
m_map0
"Shortcut" handle to m_map[0]
|
protected int |
m_numblocks
Number of blocks to (over)allocate by
|
Constructor and Description |
---|
SuballocatedByteVector()
Default constructor.
|
SuballocatedByteVector(int blocksize)
Construct a ByteVector, using the given block size.
|
SuballocatedByteVector(int blocksize,
int increaseSize)
Construct a ByteVector, using the given block size.
|
Modifier and Type | Method and Description |
---|---|
void |
addElement(byte value)
Append a byte onto the vector.
|
byte |
elementAt(int i)
Get the nth element.
|
int |
indexOf(byte elem)
Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method.
|
int |
indexOf(byte elem,
int index)
Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method.
|
void |
removeAllElements()
Wipe it out.
|
void |
setElementAt(byte value,
int at)
Sets the component at the specified index of this vector to be the
specified object.
|
int |
size()
Get the length of the list.
|
protected int m_blocksize
protected int m_numblocks
protected byte[][] m_map
protected int m_firstFree
protected byte[] m_map0
public SuballocatedByteVector()
public SuballocatedByteVector(int blocksize)
blocksize
- Size of block to allocatepublic SuballocatedByteVector(int blocksize, int increaseSize)
blocksize
- Size of block to allocatepublic int size()
public void addElement(byte value)
value
- Byte to add to the listpublic void removeAllElements()
public void setElementAt(byte value, int at)
value
- at
- Index of where to set the objectpublic byte elementAt(int i)
i
- index of value to getArrayIndexOutOfBoundsException
- if the index was _clearly_
unreasonable (negative, or past the highest block).NullPointerException
- if the index points to a block that could
have existed (based on the highest index used) but has never had anything
set into it.
%REVIEW% Could add a catch to create the block in that case, or return 0.
Try/Catch is _supposed_ to be nearly free when not thrown to. Do we
believe that? Should we have a separate safeElementAt?public int indexOf(byte elem, int index)
elem
- object to look forindex
- Index of where to begin searchpublic int indexOf(byte elem)
elem
- object to look forCopyright © 2016 JBoss by Red Hat. All rights reserved.