Modifier and Type | Field and Description |
---|---|
private int |
actualSizeInWords
The actual size in words.
|
private int[] |
buffer
The buffer (array of 32-bit words)
|
private static int |
DEFAULT_BUFFER_SIZE
The Constant DEFAULT_BUFFER_SIZE: default memory allocation when the
object is constructed.
|
Constructor and Description |
---|
IntArray()
Creates a buffer with default size
|
IntArray(int bufferSize)
Creates a buffer with explicit size
|
Modifier and Type | Method and Description |
---|---|
void |
andLastWord(int mask)
Replaces the last word position in the buffer
with its bitwise-and with the given mask.
|
void |
andWord(int position,
int mask)
Replaces the word at the given position in the buffer
with its bitwise-and with the given mask.
|
void |
clear()
Resets the buffer
The buffer is not fully cleared and any new set operations should
overwrite stale data
|
IntArray |
clone()
Creates and returns a copy of the buffer
|
void |
collapse(int position,
int length)
Removes a given number of words at the given position in the buffer.
|
void |
ensureCapacity(int capacity)
Increases the size of the buffer if necessary
|
void |
expand(int position,
int length)
Expands the buffer by adding the given number of words at the given position.
|
int |
getLastWord()
Returns the last word of the buffer
|
int |
getWord(int position)
Returns the word at a given position
|
void |
negateWord(int position)
Negates the word at the given position in the buffer
|
void |
negative_push_back(Buffer32 buffer,
int start,
int number)
Same as push_back, but the words are negated.
|
private int |
newSizeInWords(int number)
Returns the resulting buffer size in words given the number of words to add.
|
void |
orLastWord(int mask)
Replaces the last word position in the buffer
with its bitwise-or with the given mask.
|
void |
orWord(int position,
int mask)
Replaces the word at the given position in the buffer
with its bitwise-or with the given mask.
|
void |
push_back(Buffer32 buffer,
int start,
int number)
Appends the specified buffer words to the end of the buffer.
|
void |
push_back(int word)
Appends the specified word to the end of the buffer
|
void |
removeLastWord()
Removes the last word from the buffer
|
private void |
resizeBuffer(int number)
Resizes the buffer if the number of words to add exceeds the buffer capacity.
|
void |
setLastWord(int word)
Replaces the last word in the buffer with
the specified word.
|
void |
setWord(int position,
int word)
Replaces the word at the given position in the buffer with
the specified word.
|
int |
sizeInWords()
Returns the actual size in words
|
void |
swap(Buffer32 other)
Swap the content of the buffer with another.
|
void |
trim()
Reduces the internal buffer to its minimal allowable size.
|
private int actualSizeInWords
private int[] buffer
private static final int DEFAULT_BUFFER_SIZE
public IntArray()
public IntArray(int bufferSize)
bufferSize
- public int sizeInWords()
Buffer32
sizeInWords
in interface Buffer32
public void ensureCapacity(int capacity)
Buffer32
ensureCapacity
in interface Buffer32
public int getWord(int position)
Buffer32
public int getLastWord()
Buffer32
getLastWord
in interface Buffer32
public void clear()
Buffer32
public void trim()
Buffer32
public void setWord(int position, int word)
Buffer32
public void setLastWord(int word)
Buffer32
setLastWord
in interface Buffer32
public void push_back(int word)
Buffer32
public void push_back(Buffer32 buffer, int start, int number)
Buffer32
public void negative_push_back(Buffer32 buffer, int start, int number)
Buffer32
negative_push_back
in interface Buffer32
buffer
- the bufferstart
- the position of the first word to addnumber
- the number of words to addpublic void removeLastWord()
Buffer32
removeLastWord
in interface Buffer32
public void negateWord(int position)
Buffer32
negateWord
in interface Buffer32
public void andWord(int position, int mask)
Buffer32
public void orWord(int position, int mask)
Buffer32
public void andLastWord(int mask)
Buffer32
andLastWord
in interface Buffer32
public void orLastWord(int mask)
Buffer32
orLastWord
in interface Buffer32
public void expand(int position, int length)
Buffer32
public void collapse(int position, int length)
Buffer32
public IntArray clone()
Buffer32
public void swap(Buffer32 other)
Buffer32
private void resizeBuffer(int number)
number
- the number of words to addprivate int newSizeInWords(int number)
number
- the number of words to add