| Modifier and Type | Field and Description |
|---|---|
private int |
actualSizeInWords
The actual size in words.
|
private long[] |
buffer
The buffer (array of 64-bit words)
|
private static int |
DEFAULT_BUFFER_SIZE
The Constant DEFAULT_BUFFER_SIZE: default memory allocation when the
object is constructed.
|
| Constructor and Description |
|---|
LongArray()
Creates a buffer with default size
|
LongArray(int bufferSize)
Creates a buffer with explicit size
|
| Modifier and Type | Method and Description |
|---|---|
void |
andLastWord(long mask)
Replaces the last word position in the buffer
with its bitwise-and with the given mask.
|
void |
andWord(int position,
long 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
|
LongArray |
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.
|
long |
getLastWord()
Returns the last word of the buffer
|
long |
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(Buffer 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(long mask)
Replaces the last word position in the buffer
with its bitwise-or with the given mask.
|
void |
orWord(int position,
long mask)
Replaces the word at the given position in the buffer
with its bitwise-or with the given mask.
|
void |
push_back(Buffer buffer,
int start,
int number)
Appends the specified buffer words to the end of the buffer.
|
void |
push_back(long 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(long word)
Replaces the last word in the buffer with
the specified word.
|
void |
setWord(int position,
long 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(Buffer other)
Swap the content of the buffer with another.
|
void |
trim()
Reduces the internal buffer to its minimal allowable size.
|
private int actualSizeInWords
private long[] buffer
private static final int DEFAULT_BUFFER_SIZE
public LongArray()
public LongArray(int bufferSize)
bufferSize - public int sizeInWords()
BuffersizeInWords in interface Bufferpublic void ensureCapacity(int capacity)
BufferensureCapacity in interface Bufferpublic long getWord(int position)
Bufferpublic long getLastWord()
BuffergetLastWord in interface Bufferpublic void clear()
Bufferpublic void trim()
Bufferpublic void setWord(int position,
long word)
Bufferpublic void setLastWord(long word)
BuffersetLastWord in interface Bufferpublic void push_back(long word)
Bufferpublic void push_back(Buffer buffer, int start, int number)
Bufferpublic void negative_push_back(Buffer buffer, int start, int number)
Buffernegative_push_back in interface Bufferbuffer - the bufferstart - the position of the first word to addnumber - the number of words to addpublic void removeLastWord()
BufferremoveLastWord in interface Bufferpublic void negateWord(int position)
BuffernegateWord in interface Bufferpublic void andWord(int position,
long mask)
Bufferpublic void orWord(int position,
long mask)
Bufferpublic void andLastWord(long mask)
BufferandLastWord in interface Bufferpublic void orLastWord(long mask)
BufferorLastWord in interface Bufferpublic void expand(int position,
int length)
Bufferpublic void collapse(int position,
int length)
Bufferpublic LongArray clone()
Bufferpublic void swap(Buffer other)
Bufferprivate void resizeBuffer(int number)
number - the number of words to addprivate int newSizeInWords(int number)
number - the number of words to add