|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.NodeDeque
Implementation of the Deque interface by means of a doubly linked list. This class uses class DLNode, which implements a node of the list.
Field Summary | |
protected DLNode |
header
|
protected int |
size
|
protected DLNode |
trailer
|
Constructor Summary | |
NodeDeque()
Creates an empty deque. |
Method Summary | |
Object |
first()
Inspect the first element without modifying the deque. |
void |
insertFirst(Object o)
Insert an element at the beginning. |
void |
insertLast(Object o)
Insert an element at the end. |
boolean |
isEmpty()
This function returns true if and only if the deque is empty |
Object |
last()
Gets the last element (without modifying the deque). |
Object |
removeFirst()
Remove the element at the beginning. |
Object |
removeLast()
Remove the element at the end. |
int |
size()
Return the size of the deque, that is the number of elements it has. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected DLNode header
protected DLNode trailer
protected int size
Constructor Detail |
public NodeDeque()
Method Detail |
public int size()
size
in interface Deque
public boolean isEmpty()
isEmpty
in interface Deque
public Object first() throws EmptyDequeException
first
in interface Deque
EmptyDequeException
- if the deque is emptypublic Object last() throws EmptyDequeException
Deque
last
in interface Deque
EmptyDequeException
- if the deque is emptypublic void insertFirst(Object o)
Deque
insertFirst
in interface Deque
o
- new element to be inserted.public void insertLast(Object o)
Deque
insertLast
in interface Deque
o
- new element to be inserted.public Object removeFirst() throws EmptyDequeException
Deque
removeFirst
in interface Deque
EmptyDequeException
- if the deque is emptypublic Object removeLast() throws EmptyDequeException
Deque
removeLast
in interface Deque
EmptyDequeException
- if the deque is empty
|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |