forked from droberts-sea/ads-collections
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathdll_queue.js
More file actions
69 lines (56 loc) · 1.22 KB
/
dll_queue.js
File metadata and controls
69 lines (56 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import DoublyLinkedList from './doubly_linked_list';
/**
* Implementation of the Queue interface using a doubly-linked list
*/
class DLLQueue {
/**
* Create an empty queue
*/
constructor() {
this.storage = new DoublyLinkedList();
}
/**
* Add an element to the back of the queue
*
* @param {any} element Data to track
* @returns {ticket} Cancellation ticket
*/
enqueue(element) {
}
/**
* Remove an element from the queue
*
* @param {ticket} ticket Cancellation ticket, as returned by `enqueue`
* @returns Stored element
*/
cancel(ticket) {
}
/**
* Remove the element at the front of the queue
*
* @returns Stored element
*/
dequeue() {
}
/**
* How many elements are currently in the queue?
*
* @returns {number} Current count
*/
count() {
}
/**
* @callback forEachCallback
* @param element The element stored at this position
* @param {number} index The index of this element
* @param {DLLQueue} queue This queue
*/
/**
* Invoke a callback on each element in the queue, in insertion order
*
* @param {forEachCallback} callback Function to invoke
*/
forEach(callback) {
}
}
export default DLLQueue;