Created
July 27, 2018 16:54
-
-
Save elderbas/aa7117ff775c849a3debcb9e92323ead to your computer and use it in GitHub Desktop.
ExistenceDictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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