|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xith3d.utility.general.CircularArray<T>
public class CircularArray<T>
Java's internal LinkedList implementation is extremely GC expensive.
This Array-embedded implemention is better.
The CircularArray is a special kind of a Stack. Elements are dropped in (push)
in the array at a certain position and are removed (pop) at another certain position.
These position are generally not the backing array's first and last positions,
but can be anywhere. When the array's last element has been written, the array's
first element will be the next and so forth.
So the position of an element in the backing array is (i % array.length).
| Constructor Summary | |
|---|---|
CircularArray(int size)
Creates a new CircularArray with a backing array of the specified size. |
|
| Method Summary | |
|---|---|
boolean |
isEmpty()
|
T |
peek()
Sneaks the CircularArray, if there is any Element to be retrieved by pop(), but does not remove it. |
T |
pop()
Retrieves and removes the next element in question. |
void |
push(T o)
Stores the object at the next position. |
int |
size()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CircularArray(int size)
size - | Method Detail |
|---|
public final int size()
public final boolean isEmpty()
true, if the CircularArray holds at least one Element.public final void push(T o)
o - public final T peek()
pop()public final T pop()
peek()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||