public class ShiftList<T> extends java.lang.Object implements IQueue<T>
Queue like behavior performs better than a plain ArrayList, since it automatically shift the contents of its internal Array only when really necessary.
Besides sparse allocations to increase the size of the internal Array, ShiftList is allocation free (unlike the LinkedList family).
Supports null items.
(c) Zynga 2012| Modifier and Type | Field and Description |
|---|---|
protected int |
mHead |
protected java.lang.Object[] |
mItems |
protected int |
mTail |
| Constructor and Description |
|---|
ShiftList() |
ShiftList(int pInitialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int pIndex,
T pItem) |
void |
add(T pItem) |
void |
clear() |
void |
enter(int pIndex,
T pItem) |
void |
enter(T pItem) |
T |
get(int pIndex) |
int |
indexOf(T pItem) |
boolean |
isEmpty() |
T |
peek() |
T |
poll() |
T |
remove(int pIndex) |
boolean |
remove(T pItem) |
T |
removeFirst() |
T |
removeLast() |
void |
set(int pIndex,
T pItem) |
void |
shift() |
int |
size() |
protected java.lang.Object[] mItems
protected int mHead
protected int mTail
public T get(int pIndex) throws java.lang.ArrayIndexOutOfBoundsException
public void set(int pIndex,
T pItem)
throws java.lang.IndexOutOfBoundsException
public void enter(int pIndex,
T pItem)
throws java.lang.ArrayIndexOutOfBoundsException
public void add(int pIndex,
T pItem)
throws java.lang.ArrayIndexOutOfBoundsException
public T removeFirst()
removeFirst in interface IList<T>public T removeLast()
removeLast in interface IList<T>public T remove(int pIndex) throws java.lang.ArrayIndexOutOfBoundsException
public void shift()