java.lang.Object | |
↳ | android.support.v4.util.CircularArray<E> |
CircularArray is a generic circular array data structure that provides O(1) random read, O(1) prepend and O(1) append. The CircularArray automatically grows its capacity when number of added items is over its capacity.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a CircularArray with default capacity.
| |||||||||||
Create a CircularArray with capacity for at least minCapacity elements.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add an element in front of the CircularArray.
| |||||||||||
Add an element at end of the CircularArray.
| |||||||||||
Remove all elements from the CircularArray.
| |||||||||||
Get nth (0 <= n <= size()-1) element of the CircularArray.
| |||||||||||
Get first element of the CircularArray.
| |||||||||||
Get last element of the CircularArray.
| |||||||||||
Return true if size() is 0.
| |||||||||||
Remove first element from front of the CircularArray and return it.
| |||||||||||
Remove last element from end of the CircularArray and return it.
| |||||||||||
Remove multiple elements from end of the CircularArray, ignore when numOfElements
is less than or equals to 0.
| |||||||||||
Remove multiple elements from front of the CircularArray, ignore when numOfElements
is less than or equals to 0.
| |||||||||||
Get number of elements in the CircularArray.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Create a CircularArray with default capacity.
Create a CircularArray with capacity for at least minCapacity elements.
minCapacity | The minimum capacity required for the CircularArray. |
---|
Add an element in front of the CircularArray.
e | Element to add. |
---|
Add an element at end of the CircularArray.
e | Element to add. |
---|
Remove all elements from the CircularArray.
Get nth (0 <= n <= size()-1) element of the CircularArray.
n | The zero based element index in the CircularArray. |
---|
ArrayIndexOutOfBoundsException} if n < 0 or n >= size(). |
Get first element of the CircularArray.
ArrayIndexOutOfBoundsException} if CircularArray is empty. |
Get last element of the CircularArray.
ArrayIndexOutOfBoundsException} if CircularArray is empty. |
Return true if size() is 0.
Remove first element from front of the CircularArray and return it.
ArrayIndexOutOfBoundsException} if CircularArray is empty. |
Remove last element from end of the CircularArray and return it.
ArrayIndexOutOfBoundsException} if CircularArray is empty. |
Remove multiple elements from end of the CircularArray, ignore when numOfElements is less than or equals to 0.
numOfElements | Number of elements to remove. |
---|
ArrayIndexOutOfBoundsException} if numOfElements is larger than
size()
|
Remove multiple elements from front of the CircularArray, ignore when numOfElements is less than or equals to 0.
numOfElements | Number of elements to remove. |
---|
ArrayIndexOutOfBoundsException} if numOfElements is larger than
size()
|
Get number of elements in the CircularArray.