MCPcopy Index your code
hub / github.com/TypeScriptToLua/TypeScriptToLua / delete

Method delete

src/lualib/Set.ts:61–88  ·  view source on GitHub ↗
(value: T)

Source from the content-addressed store, hash-verified

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()) {

Callers 2

differenceMethod · 0.95
symmetricDifferenceMethod · 0.95

Calls 3

hasMethod · 0.95
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected