|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Deque
A "deque" is a double-ended queue: it is a data structure which restricts access to ends. This particular deque class is capable of only storing doubles. Each Deque has a "capacity" which is the number of elements the Deque can hold before the Deque is automatically expanded.
When a deque is first created, it is empty.
Constructor Summary | |
Deque()
Creates an empty Deque |
|
Deque(int capacity)
Creates an empty deque with the specified initial capacity |
Method Summary | |
void |
addBack(double element)
Adds the specified element to the back of this Deque. |
void |
addFront(double element)
Adds the specified element to the front of this Deque. |
boolean |
isEmpty()
Returns true if the there are no elements in this Deque, false otherwise |
double |
peekBack()
Returns the element at the back of this Deque. |
double |
peekFront()
Returns the element at the front of this Deque. |
double |
removeBack()
Removes and returns the element at the back of this Deque. |
double |
removeFront()
Removes and returns the element at the front of this Deque. |
int |
size()
Returns the number of elements currently in this Deque |
java.lang.String |
toString()
Returns a String representation of this Deque from front to back. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Deque()
public Deque(int capacity)
capacity
- the initial capacity of this DequeMethod Detail |
public void addFront(double element)
element
- the element to tadd ot this Dequepublic void addBack(double element)
element
- the element to tadd ot this Dequepublic double peekFront()
public double peekBack()
public double removeFront()
public double removeBack()
public java.lang.String toString()
Deque dq = new Deque(); // toString() returns "[]" dq.addFront(0.2); // toString() returns "[0.2]" dq.addBack(0.1); // toString() returns "[0.2, 0.1]" dq.addFront(0.3); // toString() returns "[0.3, 0.2, 0.1]"
public int size()
public boolean isEmpty()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |