(value: T)
| 59 | } |
| 60 | |
| 61 | public delete(value: T): boolean { |
| 62 | const contains = this.has(value); |
| 63 | if (contains) { |
| 64 | this.size--; |
| 65 | |
| 66 | // Do order bookkeeping |
| 67 | const next = this.nextKey.get(value); |
| 68 | const previous = this.previousKey.get(value); |
| 69 | if (next !== undefined && previous !== undefined) { |
| 70 | this.nextKey.set(previous, next); |
| 71 | this.previousKey.set(next, previous); |
| 72 | } else if (next !== undefined) { |
| 73 | this.firstKey = next; |
| 74 | this.previousKey.set(next, undefined!); |
| 75 | } else if (previous !== undefined) { |
| 76 | this.lastKey = previous; |
| 77 | this.nextKey.set(previous, undefined!); |
| 78 | } else { |
| 79 | this.firstKey = undefined; |
| 80 | this.lastKey = undefined; |
| 81 | } |
| 82 | |
| 83 | this.nextKey.set(value, undefined!); |
| 84 | this.previousKey.set(value, undefined!); |
| 85 | } |
| 86 | |
| 87 | return contains; |
| 88 | } |
| 89 | |
| 90 | public forEach(callback: (value: T, key: T, set: Set<T>) => any): void { |
| 91 | for (const key of this.keys()) { |
no test coverage detected