Package com.googlecode.javaewah
Class LongBufferWrapper
java.lang.Object
com.googlecode.javaewah.LongBufferWrapper
- All Implemented Interfaces:
Buffer
java.nio.LongBuffer wrapper.
Users should not be concerned by this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
The actual size in words.private LongBuffer
The buffer -
Constructor Summary
ConstructorsConstructorDescriptionLongBufferWrapper
(LongBuffer buffer) LongBufferWrapper
(LongBuffer slice, int sizeInWords) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 dataclone()
Creates and returns a copy of the buffervoid
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 necessaryvoid
expand
(int position, int length) Expands the buffer by adding the given number of words at the given position.long
Returns the last word of the bufferlong
getWord
(int position) Returns the word at a given positionvoid
negateWord
(int position) Negates the word at the given position in the buffervoid
negative_push_back
(Buffer buffer, int start, int number) Same as push_back, but the words are negated.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
(long word) Appends the specified word to the end of the buffervoid
Appends the specified buffer words to the end of the buffer.void
Removes the last word from the buffervoid
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
Returns the actual size in wordsvoid
Swap the content of the buffer with another.void
trim()
Reduces the internal buffer to its minimal allowable size.
-
Field Details
-
actualSizeInWords
private int actualSizeInWordsThe actual size in words. -
buffer
The buffer
-
-
Constructor Details
-
LongBufferWrapper
-
LongBufferWrapper
-
-
Method Details
-
sizeInWords
public int sizeInWords()Description copied from interface:Buffer
Returns the actual size in words- Specified by:
sizeInWords
in interfaceBuffer
-
ensureCapacity
public void ensureCapacity(int capacity) Description copied from interface:Buffer
Increases the size of the buffer if necessary- Specified by:
ensureCapacity
in interfaceBuffer
-
getWord
public long getWord(int position) Description copied from interface:Buffer
Returns the word at a given position -
getLastWord
public long getLastWord()Description copied from interface:Buffer
Returns the last word of the buffer- Specified by:
getLastWord
in interfaceBuffer
- Returns:
- the last word
-
clear
public void clear()Description copied from interface:Buffer
Resets 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:Buffer
Reduces the internal buffer to its minimal allowable size. This can free memory. -
setWord
public void setWord(int position, long word) Description copied from interface:Buffer
Replaces the word at the given position in the buffer with the specified word. -
setLastWord
public void setLastWord(long word) Description copied from interface:Buffer
Replaces the last word in the buffer with the specified word.- Specified by:
setLastWord
in interfaceBuffer
-
push_back
public void push_back(long word) Description copied from interface:Buffer
Appends the specified word to the end of the buffer -
push_back
Description copied from interface:Buffer
Appends the specified buffer words to the end of the buffer. -
negative_push_back
Description copied from interface:Buffer
Same as push_back, but the words are negated.- Specified by:
negative_push_back
in interfaceBuffer
- 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:Buffer
Removes the last word from the buffer- Specified by:
removeLastWord
in interfaceBuffer
-
negateWord
public void negateWord(int position) Description copied from interface:Buffer
Negates the word at the given position in the buffer- Specified by:
negateWord
in interfaceBuffer
-
andWord
public void andWord(int position, long mask) Description copied from interface:Buffer
Replaces the word at the given position in the buffer with its bitwise-and with the given mask. -
orWord
public void orWord(int position, long mask) Description copied from interface:Buffer
Replaces the word at the given position in the buffer with its bitwise-or with the given mask. -
andLastWord
public void andLastWord(long mask) Description copied from interface:Buffer
Replaces the last word position in the buffer with its bitwise-and with the given mask.- Specified by:
andLastWord
in interfaceBuffer
-
orLastWord
public void orLastWord(long mask) Description copied from interface:Buffer
Replaces the last word position in the buffer with its bitwise-or with the given mask.- Specified by:
orLastWord
in interfaceBuffer
-
expand
public void expand(int position, int length) Description copied from interface:Buffer
Expands 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:Buffer
Removes 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:Buffer
Creates and returns a copy of the buffer- Specified by:
clone
in interfaceBuffer
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
swap
Description copied from interface:Buffer
Swap the content of the buffer with another.
-