@coderbaba/stl-js
Version:
STL data structures for JavaScript
38 lines (28 loc) • 671 B
text/typescript
class UnorderedSet<T> {
private set: Set<T>;
constructor() {
this.set = new Set < T > ();
}
add(value: T): void {
this.set.add(value);
}
has(value: T): boolean {
return this.set.has(value);
}
delete(value: T): boolean {
return this.set.delete(value);
}
clear(): void {
this.set.clear();
}
size(): number {
return this.set.size;
}
values(): T[] {
return Array.from(this.set.values());
}
forEach(callback: (value: T) => void): void {
this.set.forEach(callback);
}
}
export default UnorderedSet;