-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
108 lines (75 loc) · 2.46 KB
/
index.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'use strict';
const log = function(x) { console.log(x); };
const table = function(x) { console.table(x); };
const SingLinkedList = require('./singLinkedList');
const DoubLinkList = require('./doubLinkList');
const linksList = ['Sword', 'Shield', 'Tunic', 'Net'];
const sList = new SingLinkedList();
const dList = new DoubLinkList();
log(dList.isEmpty());
log(sList.isEmpty());
linksList.forEach(item => dList.push(item));
table(dList.listContents());
dList.insertAfter('Sword', 'Potion');
table(dList.listContents());
dList.invert();
table(dList.listContents());
linksList.forEach(item => dList.push(item));
table(dList.listContents());
dList.cullDupes();
table(dList.listContents());
/*
sList.invert();
table(sList.listContents());
sList.insertAfter('Tunic', 'Bow');
table(sList.listContents());
linksList.forEach(item => sList.push(item));
table(sList.listContents());
sList.pop();
sList.pop();
table(sList.listContents());
linksList.forEach(item => dList.push(item));
table(dList.listContents());
linksList.forEach(item => dList.shift(item));
log(`Length - ${dList.listLength()}:`);
table(dList.listContents());
dList.millet();
log(`Length - ${dList.listLength()}:`);
table(dList.listContents());
dList.pop();
dList.pop();
table(dList.listContents());
log(`The shield is ${dList.findFromHead('Shield')} from the head`);
log(`The other shield is at position ${dList.findFromTail('Shield')}`);
log(dList.scry());
log(dList.peek());
>>= ~> single list test <~ =<<
sList.pin('Sword');
table(sList.listContents());
sList.pin('Shield');
sList.pin('Wand');
sList.pin('Bottle');
log(sList);
log(sList.listContents());
log(sList.isEmpty());
log(`The list is ${sList.listSize()} items long.`);
table(sList.listContents());
log(sList.scry());
sList.millet();
log(sList.scry());
log(`Contains the Sword?: ${sList.doesContain('Sword')}`);
log(`Contains the Bottle?: ${sList.doesContain('Bottle')}`);
log(`Contains the Wand?: ${sList.doesContain('Wand')}`);
log(`Wand is at index: ${sList.indexOf('Wand')}`);
log(`The list is ${sList.listSize()} items long.`);
linksList.extract('Shield');
log(`Contains the Shield?: ${linksList.doesContain('Shield')}`);
log(`The list is ${linksList.listSize()} items long.`);
table(linksList.listContents());
log(`The list is ${linksList.listSize()} items long.`);
table(linksList.listContents());
linksList.insertEntryAt('Potion', 1);
log(`The list is ${linksList.listSize()} items long.`);
table(linksList.listContents());
log(linksList);
*/