From 3090e1624034cfa49742d4e67032acc4a6b47bf7 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 14 Jul 2016 13:16:32 +0200 Subject: [PATCH] add each and equals to hashset --- hashset.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hashset.js b/hashset.js index d65da5d..1cba7f6 100644 --- a/hashset.js +++ b/hashset.js @@ -65,6 +65,17 @@ function HashSet(param1, param2) { return hashTable.isEmpty(); }; + this.each = function(callback) { + hashTable.each(function(key, value) { callback(key); }); + }; + + this.equals = function(other) { + if (!other.hasOwnProperty("hashTable")) { + return false; + } + return hashTable.equals(other.hashTable); + }; + this.clone = function() { var h = new HashSet(param1, param2); h.addAll(hashTable.keys());