public final class CircularIntArray extends Object
| Constructor and Description |
|---|
CircularIntArray()
Create a CircularIntArray with default capacity.
|
CircularIntArray(int minCapacity)
Create a CircularIntArray with capacity for at least minCapacity elements.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFirst(int e)
Add an integer in front of the CircularIntArray.
|
void |
addLast(int e)
Add an integer at end of the CircularIntArray.
|
void |
clear()
Remove all integers from the CircularIntArray.
|
int |
get(int n)
Get nth (0 <= n <= size()-1) integer of the CircularIntArray.
|
int |
getFirst()
Get first integer of the CircularIntArray.
|
int |
getLast()
Get last integer of the CircularIntArray.
|
boolean |
isEmpty()
Return true if size() is 0.
|
int |
popFirst()
Remove first integer from front of the CircularIntArray and return it.
|
int |
popLast()
Remove last integer from end of the CircularIntArray and return it.
|
void |
removeFromEnd(int numOfElements)
Remove multiple elements from end of the CircularIntArray, ignore when numOfElements
is less than or equals to 0.
|
void |
removeFromStart(int numOfElements)
Remove multiple integers from front of the CircularIntArray, ignore when numOfElements
is less than or equals to 0.
|
int |
size()
Get number of integers in the CircularIntArray.
|
public CircularIntArray()
public CircularIntArray(int minCapacity)
minCapacity - The minimum capacity required for the CircularIntArray.public void addFirst(int e)
e - Integer to add.public void addLast(int e)
e - Integer to add.public int popFirst()
ArrayIndexOutOfBoundsException - if CircularIntArray is empty.public int popLast()
ArrayIndexOutOfBoundsException - if CircularIntArray is empty.public void clear()
public void removeFromStart(int numOfElements)
numOfElements - Number of integers to remove.ArrayIndexOutOfBoundsException - if numOfElements is larger than
size()public void removeFromEnd(int numOfElements)
numOfElements - Number of integers to remove.ArrayIndexOutOfBoundsException - if numOfElements is larger than
size()public int getFirst()
{@link - ArrayIndexOutOfBoundsException} if CircularIntArray is empty.public int getLast()
{@link - ArrayIndexOutOfBoundsException} if CircularIntArray is empty.public int get(int n)
n - The zero based element index in the CircularIntArray.{@link - ArrayIndexOutOfBoundsException} if n < 0 or n >= size().public int size()
public boolean isEmpty()
Copyright © 2015. All rights reserved.