Skip to content

Instantly share code, notes, and snippets.

@liamgriffiths
Last active January 1, 2016 22:59
Show Gist options
  • Save liamgriffiths/8213549 to your computer and use it in GitHub Desktop.
Save liamgriffiths/8213549 to your computer and use it in GitHub Desktop.
set data structure built on top of js object
var Set = function() {
this._items = {};
};
Set.prototype = {
values: function() {
return Object.keys(this._items);
},
insert: function(val) {
if (this._items[val]) return false;
this._items[val] = true;
return true;
},
remove: function(val) { delete(this._items[val]); }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment