|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectariba.util.core.Deque
public class Deque
This class implements a double-ended queue (pronounced like "deck"). It has the behavior that each operation is in constant (amortized) time. It supports FIFO operation with the enqueue and dequeue methods, and LIFO with push and pop methods. Both access methods may be used on a single deque. This is a similar interface to the deque described in Intorduction to Algorithms by Cormen, Leiserson and Rivest: Eighth printing in chapter 11 (Elementary Data Structures) section 1 (Stacks and queues)
Constructor Summary | |
---|---|
Deque()
Construct a deque with a default capacity. |
|
Deque(int initialCapacity)
Construct a deque with a given initial capacity. |
Method Summary | |
---|---|
int |
count()
Check the number of elements in the deque. |
java.lang.Object |
debugState()
Iterates through the deque from head to tail and calls toString on each node |
java.lang.Object |
dequeue()
Dequeues from the deque. |
void |
enqueue(java.lang.Object o)
Enqueues an object into the deque. |
boolean |
isEmpty()
Check if the deque is empty. |
java.lang.Object |
peekDequeue()
Peek in the deque without removing it. |
java.lang.Object |
peekPop()
Peek into the deque without removing any elements. |
java.lang.Object |
pop()
Pops an element from the deque. |
void |
push(java.lang.Object o)
Pushes an object onto the deque in the manner of a stack. |
void |
setSize(int size)
Set the size for the internal storage. |
int |
size()
Check the number of elements in the deque. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Deque()
public Deque(int initialCapacity)
initialCapacity
- the minimum number of elements that the
deque is required to hold before having to grow the internal
storage.Method Detail |
---|
public void enqueue(java.lang.Object o)
o
- the object to enqueuepublic java.lang.Object dequeue()
public java.lang.Object peekDequeue()
public void push(java.lang.Object o)
o
- the object to enqueueenqueue(Object)
public java.lang.Object peekPop()
public java.lang.Object pop()
public void setSize(int size)
size
- the new size for the internal storage. This must
be greater than or equal to the count and may not be zero.public int count()
public int size()
public boolean isEmpty()
true
if and only if the deque is empty.public java.lang.Object debugState()
debugState
in interface DebugState
ThreadDebugState.set(ariba.util.core.ThreadDebugKey, java.lang.Object)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |