repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1831 from poolifier/dependabot/npm_and_yarn/examples/typescript...
[poolifier.git]
/
src
/
deque.ts
diff --git
a/src/deque.ts
b/src/deque.ts
index 2eae8034845789b4991c3d1435c24f7050726c42..fe82a79896a08757e3f261b66aa364b1407ab6e9 100644
(file)
--- a/
src/deque.ts
+++ b/
src/deque.ts
@@
-76,14
+76,14
@@
export class Deque<T> {
*/
public pop (): T | undefined {
if (this.head == null) {
*/
public pop (): T | undefined {
if (this.head == null) {
- return
undefined
+ return
}
const tail = this.tail
}
const tail = this.tail
- this.tail =
(this.tail as Node<T>)
.prev
+ this.tail =
this.tail?
.prev
if (this.tail == null) {
if (this.tail == null) {
-
this.head = undefine
d
+
delete this.hea
d
} else {
} else {
- this.tail.next = undefined
+ delete this.tail.next
}
--this.size
return tail?.data
}
--this.size
return tail?.data
@@
-96,17
+96,17
@@
export class Deque<T> {
*/
public shift (): T | undefined {
if (this.head == null) {
*/
public shift (): T | undefined {
if (this.head == null) {
- return
undefined
+ return
}
const head = this.head
this.head = this.head.next
if (this.head == null) {
}
const head = this.head
this.head = this.head.next
if (this.head == null) {
- this.tail = undefined
+ delete this.tail
} else {
} else {
- this.head.prev = undefined
+ delete this.head.prev
}
--this.size
}
--this.size
- return head
?
.data
+ return head.data
}
/**
}
/**
@@
-129,8
+129,8
@@
export class Deque<T> {
* Clears the deque.
*/
public clear (): void {
* Clears the deque.
*/
public clear (): void {
-
this.head = undefine
d
- this.tail = undefined
+
delete this.hea
d
+ delete this.tail
this.size = 0
this.maxSize = 0
}
this.size = 0
this.maxSize = 0
}
@@
-155,7
+155,7
@@
export class Deque<T> {
value: node.data,
done: false
}
value: node.data,
done: false
}
- node = node.next
as Node<T>
+ node = node.next
return ret
}
}
return ret
}
}
@@
-183,7
+183,7
@@
export class Deque<T> {
value: node.data,
done: false
}
value: node.data,
done: false
}
- node = node.prev
as Node<T>
+ node = node.prev
return ret
}
}
return ret
}
}