-
Notifications
You must be signed in to change notification settings - Fork 34
HashSet
HashSet is similar to HashSet implementations found in Java and C#. It wraps the keys of a jshashtable hash table.
HashSet depends on jshashtable's HashTable
implementation. You will therefore need to include both jshashtable.js and jshashset.js, in that order.
Creates a new HashSet.
-
hashingFunction
An optional function that provides hash codes for keys placed in the wrapped hash table. It is passed the object to be hashed as its only parameter. If not provided, the hash table checks whether the object has ahashCode()
method, and if not, callstoString()
on the object.
-
equalityFunction
An optional function that checks for equality between two keys with the same hash code. Two keys that are considered equal will map to the same value in the hash table. This function is passed the two objects to be compared as its parameters. If not provided, the wrapped hash table checks whether either object being compared has anequals()
method, and if not, compares the objects using the===
operator.
Adds the specified object or primitive to the set. value
replaces any member of the set equal to it.
Adds all members of an array arr
to the set in descending order. Each member of arr
replaces any member of the set equal to it. Since the order is descending, this means that an earlier member overwrites an equal later member of the array within the set.
Returns an array containing all the members of the set in unspecified order.
Removes the specified value from the set.
Returns whether the set contains the specified value.
Removes all members from the set.
Returns the number of members contained in the set.
Returns true
if the set has no members, false
otherwise.
Returns true
if every member this set is also a member of otherSet
.
Creates and returns a shallow copy of the set. If hashing and equality functions were provided to the set when it was constructed, they are passed into the new set.
Creates and returns a new HashSet
containing those elements that are contained in both this set and otherSet
.
Creates and returns a new HashSet
containing those elements that are contained in one or both of this set and otherSet
.
Creates and returns a new HashSet
containing those elements that are contained in this set but not otherSet
.