The list as an ADT
- Common operations
- create
- test if empty
- LIFO (last-in/first-out) or stack operations
- push new element
- pop youngest element
- FIFO (first-in/first-out) or queue operations
- enqueue new element
- dequeue oldest element
The deque (or sometimes confusingly the dequeue) is a two-ended queue where elements can be removed and inserted on both ends.
In an priority queue elements are ordered by value.
Implementation
- Stack — singly linked list where elements are added and removed at a head node (5B-2)
- Queue — single linked list where elements are added at a head node and removed at a tail mode (5B-11)
- Deque — doubly linked list, perhaps with a dummy (5B-17)
Java Collections Framework
Interfaces
Implementations
Four Deque
methods
-
addFirst
orpush
-
removeFirst
orpop
-
addLast
- removeLast