|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.virtuosotechnologies.lib.ring.AbstractRing com.virtuosotechnologies.lib.ring.CharRing
Circular buffer of chars. This class is not thread-safe.
Constructor Summary | |
CharRing()
Constructs an empty buffer with a capacity of 16. |
|
CharRing(int initialCapacity)
Constructs an empty buffer with the specified initial capacity. |
Method Summary | |
protected Object |
allocateArray(int capacity)
Override this method to allocate an array of the desired type. |
protected void |
clearArrayValues(Object array,
int start,
int end)
Override this method to clear the specified values in the array. |
protected int |
getArrayLength(Object array)
Override this method to get the length of the array. |
char |
getChar(int index)
Gets the value of a particular char |
String |
getRange(int start,
int end)
Gets a range of values as a String. |
void |
getRange(int start,
int end,
char[] destination,
int pos)
Gets a range of values and copies it into the given array. |
void |
getRange(int start,
int end,
StringBuffer buffer)
Adds a range of values to a StringBuffer. |
protected void |
initArrayValues(Object array,
int start,
int end)
Override this method to initialize the specified values in the array. |
char |
popBack()
Pop a char from the back. |
String |
popBack(int size)
Pop a String from the back. |
void |
popBack(int size,
StringBuffer buffer)
Pop characters from the back and add to a StringBuffer |
char |
popFront()
Pop a char from the front. |
String |
popFront(int size)
Pop a String from the front. |
void |
popFront(int size,
StringBuffer buffer)
Pop characters from the front and add to a StringBuffer |
void |
pushBack(char ch)
Push a char to the back |
void |
pushBack(String str)
Push a String to the back |
void |
pushFront(char ch)
Push a char to the front |
void |
pushFront(String str)
Push a String to the front |
void |
setChar(int index,
char value)
Sets the value of a particular char |
void |
setRange(int start,
int end,
char[] source,
int pos)
Sets a range of values from the given array. |
void |
setRange(int start,
String source)
Sets a range of values from the given String. |
Methods inherited from class com.virtuosotechnologies.lib.ring.AbstractRing |
addBack, addFront, addMiddle, calculateRawIndex, clear, ensureCapacity, getRangeRaw, getRawArray, getSize, removeBack, removeFront, removeMiddle, setRangeRaw, trimToSize |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CharRing(int initialCapacity)
initialCapacity
- the initial capacity of the buffer.
IllegalArgumentException
- if the specified initial capacity
is negativepublic CharRing()
Method Detail |
protected Object allocateArray(int capacity)
allocateArray
in class AbstractRing
capacity
- size of the array to allocate
protected int getArrayLength(Object array)
getArrayLength
in class AbstractRing
array
- an array object
protected void clearArrayValues(Object array, int start, int end)
clearArrayValues
in class AbstractRing
array
- an array objectstart
- the index of the first item to clearend
- one more than the index of the last item to clearprotected void initArrayValues(Object array, int start, int end)
initArrayValues
in class AbstractRing
array
- an array objectstart
- the index of the first item to initializeend
- one more than the index of the last item to initializepublic char getChar(int index)
index
- index to query
public void setChar(int index, char value)
index
- index to setvalue
- the charpublic void getRange(int start, int end, char[] destination, int pos)
start
- starting position in the bufferend
- one more than the ending position in the bufferdestination
- destination arraypos
- starting position in the destination arraypublic String getRange(int start, int end)
start
- starting position in the bufferend
- one more than the ending position in the buffer
public void getRange(int start, int end, StringBuffer buffer)
start
- starting position in the bufferend
- one more than the ending position in the bufferbuffer
- StringBuffer to add the values topublic void setRange(int start, int end, char[] source, int pos)
start
- starting position in the bufferend
- one more than the ending position in the buffersource
- source arraypos
- starting position in the source arraypublic void setRange(int start, String source)
start
- starting position in the buffersource
- source stringpublic void pushFront(char ch)
ch
- the charpublic void pushFront(String str)
str
- the Stringpublic void pushBack(char ch)
ch
- the charpublic void pushBack(String str)
str
- the Stringpublic char popBack()
NoSuchElementException
- ring is emptypublic String popBack(int size)
size
- number of characters to pop.
NoSuchElementException
- ring isn't large enoughpublic void popBack(int size, StringBuffer buffer)
size
- number of characters to pop.buffer
- the StringBuffer
NoSuchElementException
- ring isn't large enoughpublic char popFront()
NoSuchElementException
- ring is emptypublic String popFront(int size)
size
- number of characters to pop.
NoSuchElementException
- ring isn't large enoughpublic void popFront(int size, StringBuffer buffer)
size
- number of characters to pop.buffer
- the StringBuffer
NoSuchElementException
- ring isn't large enough
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |