|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.virtuosotechnologies.lib.ring.AbstractRing
com.virtuosotechnologies.lib.ring.IntRing
Circular buffer of ints. This class is not thread-safe.
| Constructor Summary | |
IntRing()
Constructs an empty buffer with a capacity of 16. |
|
IntRing(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. |
int |
getInt(int index)
Gets the value of a particular int |
int[] |
getRange(int start,
int end)
Gets a range of values as a new array. |
void |
getRange(int start,
int end,
int[] destination,
int pos)
Gets a range of values and copies it into the given array. |
protected void |
initArrayValues(Object array,
int start,
int end)
Override this method to initialize the specified values in the array. |
int |
popBack()
Pop an int from the back. |
int[] |
popBack(int size)
Pop an int array from the back. |
void |
popBack(int size,
int[] buffer,
int pos)
Pop an int array from the back. |
int |
popFront()
Pop an int from the front. |
int[] |
popFront(int size)
Pop an int array from the front. |
void |
popFront(int size,
int[] buffer,
int pos)
Pop an int array from the front. |
void |
pushBack(int v)
Push an int to the back |
void |
pushBack(int[] array)
Push an int array to the back |
void |
pushFront(int v)
Push an int to the front |
void |
pushFront(int[] array)
Push an int array to the front |
void |
setInt(int index,
int value)
Sets the value of a particular int |
void |
setRange(int start,
int end,
int[] source,
int pos)
Sets a range of values from the given array. |
| 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 IntRing(int initialCapacity)
initialCapacity - the initial capacity of the buffer.
IllegalArgumentException - if the specified initial capacity
is negativepublic IntRing()
| Method Detail |
protected Object allocateArray(int capacity)
allocateArray in class AbstractRingcapacity - size of the array to allocate
protected int getArrayLength(Object array)
getArrayLength in class AbstractRingarray - an array object
protected void clearArrayValues(Object array,
int start,
int end)
clearArrayValues in class AbstractRingarray - an array objectstart - the index of the first item to clearend - one more than the index of the last item to clear
protected void initArrayValues(Object array,
int start,
int end)
initArrayValues in class AbstractRingarray - an array objectstart - the index of the first item to initializeend - one more than the index of the last item to initializepublic int getInt(int index)
index - index to query
public void setInt(int index,
int value)
index - index to setvalue - the byte
public void getRange(int start,
int end,
int[] 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 array
public int[] getRange(int start,
int end)
start - starting position in the bufferend - one more than the ending position in the buffer
public void setRange(int start,
int end,
int[] 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 pushFront(int v)
v - the intpublic void pushFront(int[] array)
array - the arraypublic void pushBack(int v)
v - the intpublic void pushBack(int[] array)
array - the arraypublic int popBack()
NoSuchElementException - ring is emptypublic int[] popBack(int size)
size - number of ints to pop.
NoSuchElementException - ring isn't large enough
public void popBack(int size,
int[] buffer,
int pos)
size - number of ints to pop.buffer - the array to populatepos - position in the buffer
NoSuchElementException - ring isn't large enoughpublic int popFront()
NoSuchElementException - ring is emptypublic int[] popFront(int size)
size - number of ints to pop.
NoSuchElementException - ring isn't large enough
public void popFront(int size,
int[] buffer,
int pos)
size - number of ints to pop.buffer - the array to populatepos - position in the buffer
NoSuchElementException - ring isn't large enough
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||