Package com.googlecode.javaewah32
Class IntArray
java.lang.Object
com.googlecode.javaewah32.IntArray
Int array wrapper.
Users should not be concerned by this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe actual size in words.private int[]The buffer (array of 32-bit words)private static final intThe Constant DEFAULT_BUFFER_SIZE: default memory allocation when the object is constructed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidandLastWord(int mask) Replaces the last word position in the buffer with its bitwise-and with the given mask.voidandWord(int position, int mask) Replaces the word at the given position in the buffer with its bitwise-and with the given mask.voidclear()Resets the buffer The buffer is not fully cleared and any new set operations should overwrite stale dataclone()Creates and returns a copy of the buffervoidcollapse(int position, int length) Removes a given number of words at the given position in the buffer.voidensureCapacity(int capacity) Increases the size of the buffer if necessaryvoidexpand(int position, int length) Expands the buffer by adding the given number of words at the given position.intReturns the last word of the bufferintgetWord(int position) Returns the word at a given positionvoidnegateWord(int position) Negates the word at the given position in the buffervoidnegative_push_back(Buffer32 buffer, int start, int number) Same as push_back, but the words are negated.private intnewSizeInWords(int number) Returns the resulting buffer size in words given the number of words to add.voidorLastWord(int mask) Replaces the last word position in the buffer with its bitwise-or with the given mask.voidorWord(int position, int mask) Replaces the word at the given position in the buffer with its bitwise-or with the given mask.voidpush_back(int word) Appends the specified word to the end of the buffervoidAppends the specified buffer words to the end of the buffer.voidRemoves the last word from the bufferprivate voidresizeBuffer(int number) Resizes the buffer if the number of words to add exceeds the buffer capacity.voidsetLastWord(int word) Replaces the last word in the buffer with the specified word.voidsetWord(int position, int word) Replaces the word at the given position in the buffer with the specified word.intReturns the actual size in wordsvoidSwap the content of the buffer with another.voidtrim()Reduces the internal buffer to its minimal allowable size.
-
Field Details
-
actualSizeInWords
private int actualSizeInWordsThe actual size in words. -
buffer
private int[] bufferThe buffer (array of 32-bit words) -
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZEThe Constant DEFAULT_BUFFER_SIZE: default memory allocation when the object is constructed.- See Also:
-
-
Constructor Details
-
IntArray
public IntArray()Creates a buffer with default size -
IntArray
public IntArray(int bufferSize) Creates a buffer with explicit size- Parameters:
bufferSize-
-
-
Method Details
-
sizeInWords
public int sizeInWords()Description copied from interface:Buffer32Returns the actual size in words- Specified by:
sizeInWordsin interfaceBuffer32
-
ensureCapacity
public void ensureCapacity(int capacity) Description copied from interface:Buffer32Increases the size of the buffer if necessary- Specified by:
ensureCapacityin interfaceBuffer32
-
getWord
public int getWord(int position) Description copied from interface:Buffer32Returns the word at a given position -
getLastWord
public int getLastWord()Description copied from interface:Buffer32Returns the last word of the buffer- Specified by:
getLastWordin interfaceBuffer32- Returns:
- the last word
-
clear
public void clear()Description copied from interface:Buffer32Resets the buffer The buffer is not fully cleared and any new set operations should overwrite stale data -
trim
public void trim()Description copied from interface:Buffer32Reduces the internal buffer to its minimal allowable size. This can free memory. -
setWord
public void setWord(int position, int word) Description copied from interface:Buffer32Replaces the word at the given position in the buffer with the specified word. -
setLastWord
public void setLastWord(int word) Description copied from interface:Buffer32Replaces the last word in the buffer with the specified word.- Specified by:
setLastWordin interfaceBuffer32- Parameters:
word-
-
push_back
public void push_back(int word) Description copied from interface:Buffer32Appends the specified word to the end of the buffer -
push_back
Description copied from interface:Buffer32Appends the specified buffer words to the end of the buffer. -
negative_push_back
Description copied from interface:Buffer32Same as push_back, but the words are negated.- Specified by:
negative_push_backin interfaceBuffer32- Parameters:
buffer- the bufferstart- the position of the first word to addnumber- the number of words to add
-
removeLastWord
public void removeLastWord()Description copied from interface:Buffer32Removes the last word from the buffer- Specified by:
removeLastWordin interfaceBuffer32
-
negateWord
public void negateWord(int position) Description copied from interface:Buffer32Negates the word at the given position in the buffer- Specified by:
negateWordin interfaceBuffer32- Parameters:
position-
-
andWord
public void andWord(int position, int mask) Description copied from interface:Buffer32Replaces the word at the given position in the buffer with its bitwise-and with the given mask. -
orWord
public void orWord(int position, int mask) Description copied from interface:Buffer32Replaces the word at the given position in the buffer with its bitwise-or with the given mask. -
andLastWord
public void andLastWord(int mask) Description copied from interface:Buffer32Replaces the last word position in the buffer with its bitwise-and with the given mask.- Specified by:
andLastWordin interfaceBuffer32- Parameters:
mask-
-
orLastWord
public void orLastWord(int mask) Description copied from interface:Buffer32Replaces the last word position in the buffer with its bitwise-or with the given mask.- Specified by:
orLastWordin interfaceBuffer32- Parameters:
mask-
-
expand
public void expand(int position, int length) Description copied from interface:Buffer32Expands the buffer by adding the given number of words at the given position. The added words may contain stale data. -
collapse
public void collapse(int position, int length) Description copied from interface:Buffer32Removes a given number of words at the given position in the buffer. The freed words at the end of the buffer are properly cleaned. -
clone
Description copied from interface:Buffer32Creates and returns a copy of the buffer -
swap
Description copied from interface:Buffer32Swap the content of the buffer with another. -
resizeBuffer
private void resizeBuffer(int number) Resizes the buffer if the number of words to add exceeds the buffer capacity.- Parameters:
number- the number of words to add
-
newSizeInWords
private int newSizeInWords(int number) Returns the resulting buffer size in words given the number of words to add.- Parameters:
number- the number of words to add
-