Skip to content

Instantly share code, notes, and snippets.

@jsoverson
Created May 7, 2019 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jsoverson/5f8778390f341d5a20a09dbb961f7100 to your computer and use it in GitHub Desktop.
Save jsoverson/5f8778390f341d5a20a09dbb961f7100 to your computer and use it in GitHub Desktop.
class GeneralSet {
map = new Map();
constructor(a = []) {
this[Symbol.iterator] = this.values;
if (a) a.forEach(_ => this.add(_));
}
add(el) {
this.map.set(el.toIdString(), el);
}
has(el) {
return this.map.has(el.toIdString());
}
values() {
return this.map.values();
}
delete(el) {
return this.map.delete(el.toIdString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment