Skip to content

Instantly share code, notes, and snippets.

@elderbas
Created July 27, 2018 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elderbas/aa7117ff775c849a3debcb9e92323ead to your computer and use it in GitHub Desktop.
Save elderbas/aa7117ff775c849a3debcb9e92323ead to your computer and use it in GitHub Desktop.
ExistenceDictionary
class ExistenceDictionary {
constructor(valsToAdd = []) {
this.store = {};
valsToAdd.forEach((val) => {
this.store[val] = true;
})
}
exists(val) {
return this.store[val] === true;
}
add(val) {
this.store[val] = true;
}
remove(val) {
this.store[val] = undefined;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment