summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2018-08-14 08:21:25 +0900
committerAya Morisawa <AyaMorisawa4869@gmail.com>2018-08-14 08:21:25 +0900
commitbde20a1a651fca49cd2fe1806cba758602d7626c (patch)
treeb0d20d660da9f16435b9e5da4412ca21c88682e6 /src/misc
parentMerge pull request #2199 from syuilo/patch-2176 (diff)
downloadsharkey-bde20a1a651fca49cd2fe1806cba758602d7626c.tar.gz
sharkey-bde20a1a651fca49cd2fe1806cba758602d7626c.tar.bz2
sharkey-bde20a1a651fca49cd2fe1806cba758602d7626c.zip
Use deque instead of linked list
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/queue.ts33
1 files changed, 0 insertions, 33 deletions
diff --git a/src/misc/queue.ts b/src/misc/queue.ts
deleted file mode 100644
index 410878ba8b..0000000000
--- a/src/misc/queue.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-type Node<T> = { value: T, next: Node<T> };
-
-export default class Queue<T> {
- private top: Node<T> = null;
- private rear: Node<T> = null;
- public length: number = 0;
-
- public push(value: T): void {
- const node: Node<T> = { value, next: null };
- if (this.top === null) {
- this.top = node;
- this.rear = node;
- } else {
- this.rear.next = node;
- this.rear = node;
- }
- this.length++;
- }
-
- public pop(): void {
- this.top = this.top.next;
- if (this.top == null) this.rear = null;
- this.length--;
- }
-
- public toArray(): T[] {
- const arr: T[] = Array<T>(this.length);
- for (let node = this.top, i = 0; node !== null; node = node.next, i++) {
- arr[i] = node.value;
- }
- return arr;
- }
-}