-
Notifications
You must be signed in to change notification settings - Fork 0
/
demos.queue.top.js
65 lines (50 loc) · 1.38 KB
/
demos.queue.top.js
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
/**
*
* Package: queues.js
* Author: Ganesh B
* Description:
* Install: npm i queues.js --save
* Github: https://github.com/ganeshkbhat/queues.js
* npmjs Link: https://www.npmjs.com/package/queues.js
* File: .js
* File Description: .js
*
*/
/* eslint no-console: 0 */
'use strict';
var Queue = require("../index.js").QueueTop;
var queue = new Queue();
// LIFO
queue.lifo.enqueue(1);
queue.lifo.add(2);
queue.lifo.insert(3);
queue.lifo.push(4);
queue.lifo.enqueue(5);
queue.lifo.add(6);
queue.lifo.insert(7);
queue.lifo.push(8);
console.log(".size()", queue.lifo.size());
console.log(".toArray()", queue.lifo.toArray());
console.log(queue.lifo.dequeue());
console.log(queue.lifo.pop());
console.log(queue.lifo.remove());
console.log(".size()", queue.lifo.size());
console.log(".toArray()", queue.lifo.toArray());
queue.lifo.clear();
queue.lifo.reset();
// FIFO
queue.fifo.enqueue(1);
queue.fifo.add(2);
queue.fifo.insert(3);
queue.fifo.push(4);
queue.fifo.enqueue(5);
queue.fifo.add(6);
queue.fifo.insert(7);
queue.fifo.push(8);
console.log(".size()", queue.fifo.size());
console.log(".toArray()", queue.fifo.toArray());
console.log(queue.fifo.dequeue());
console.log(queue.fifo.shift());
console.log(queue.fifo.remove());
console.log(".size()", queue.fifo.size());
console.log(".toArray()", queue.fifo.toArray());