MCPcopy Index your code
hub / github.com/loiane/javascript-datastructures-algorithms / add

Method add

src/07-set/set.ts:11–18  ·  view source on GitHub ↗

* Adds a value to the set. * @param value - The value to add * @returns true if added, false if already present * @complexity Time O(1) | Space O(1)

(value: string)

Source from the content-addressed store, hash-verified

9 * @complexity Time O(1) | Space O(1)
10 */
11 add(value: string): boolean {
12 if (!this.has(value)) {
13 this.#items[value] = true;
14 this.#size++;
15 return true;
16 }
17 return false;
18 }
19
20 /**
21 * Adds multiple values to the set.

Callers 9

addAllMethod · 0.95
unionMethod · 0.95
intersectionMethod · 0.95
differenceMethod · 0.95
set.test.tsFile · 0.45

Calls 1

hasMethod · 0.95

Tested by

no test coverage detected