StacksQueues/Java/LinkedDeque
From charlesreid1
LinkedDeque is a class that implements a double ended queue using a linked list data structure.
Code
Implementation notes
To implement a double-ended queue with fast, O(1) addition and removal at the front and back of the data structure, use a doubly-linked list.
To conserve memory overhead, use a circular doubly-linked list.
Interface
The Abstract Data Types#Deques page covers the methods that deques normally implement:
- enqueueFront : add something to the front of the queue (will be the next thing to come out)
- enqueueBack : add something to the back of the queue (normal order)
- dequeueFront : remove something from the front of the queue (normal order)
- dequeueBack : remove something from the back of the queue (cutting in line)
- first : peek at first item
- last : peek at last item
- size : size of deque
- isEmpty : is deque empty
- rotate : rotate deque, move item from front to back
Test
(code for a unit test)
The Class
(code for the class)
Flags
Stacks and Queues Part of Computer Science Notes
Series on Data Structures
Stacks and Queues: Python StacksQueues/Python · StacksQueues/Python/ArrayStack · StacksQueues/Python/ArrayQueue · StacksQueues/Python/ArrayDeque StacksQueues/Python/LinkedStack
Stacks and Queues: Java StacksQueues/Java · StacksQueues/Java/ArrayStack · StacksQueues/Java/ArrayQueue · StacksQueues/Java/ArrayQueueFS · StacksQueues/Java/ArrayDeque StacksQueues/Java/LinkedStack · StacksQueues/Java/LinkedQueue · StacksQueues/Java/LinkedDeque
Applications Postfix_Expressions#Stacks · StacksQueues/Subsets · StacksQueues/Subsets/Java
|