Skip to content

Instantly share code, notes, and snippets.

@mondalaci
Created April 24, 2014 16:02
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 mondalaci/11259937 to your computer and use it in GitHub Desktop.
Save mondalaci/11259937 to your computer and use it in GitHub Desktop.
StringSet class in JavaScript
"use strict";
var StringSet = /* StringSet */ function() {
this.set = {};
this.add = /* bool */ function(/* String */ string) {
var contains = this.contains(string);
this.set[string] = true;
return !contains;
};
this.remove = /* bool */ function(/* String */ string) {
var contains = this.contains(string);
delete this.set[string];
return contains;
};
this.contains = /* bool */ function(/* String */ string) {
return string in this.set;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment