-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.html
85 lines (74 loc) · 1.5 KB
/
queue.html
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
<html>
<head>
<script src="queue.js"></script>
<style>
body {
font-family: arial
}
h1 {
color: blue
}
</style>
</head>
<body>
<h1>Queue</h1>
<script>
var queueArray = [3, 251, 1922, -53, 3, 11];
var queue = new Queue(queueArray);
function printQueueAuxiliaryInfo(queue) {
document.write('<i>Size</i>: ' + queue.size());
document.write('<br/>');
document.write('<i>isEmpty</i>: ' + queue.isEmpty());
document.write('<br/>');
document.write('<br/>');
document.write(queue.toString());
}
</script>
<h3>Input List</h3>
<script>
document.write(queueArray.join(', '));
</script>
<h3>Convert to Queue</h3>
<script>
document.write('<i>Array</i>: ' + queue.toString());
document.write('<br/>');
printQueueAuxiliaryInfo(queue);
</script>
<h3>Pop</h3>
<script>
document.write('<i>Popped</i>: ' + queue.pop());
document.write('<br/>');
printQueueAuxiliaryInfo(queue);
</script>
<h3>Peek</h3>
<script>
document.write('<i>Peeked</i>: ' + queue.peek());
document.write('<br/>');
printQueueAuxiliaryInfo(queue);
</script>
<h3>Insert (20)</h3>
<script>
queue.insert(20);
printQueueAuxiliaryInfo(queue);
</script>
<h3>Pop Until 2 Items Left</h3>
<script>
while (queue.size() > 2) {
queue.pop();
}
printQueueAuxiliaryInfo(queue);
</script>
<h3>Pop Until Empty</h3>
<script>
while (!queue.isEmpty()) {
queue.pop();
}
printQueueAuxiliaryInfo(queue);
</script>
<h3>Pop from Empty Queue</h3>
<script>
queue.pop();
printQueueAuxiliaryInfo(queue);
</script>
</body>
</html>