Class Index | File Index

Classes


Class buckets.Set

A set is a data structure that contains no duplicate items.

If the inserted elements are custom objects a function which converts elements to unique strings must be provided. Example:

function petToString(pet) {
 return pet.type + ' ' + pet.name;
}

Defined in: <../buckets.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
buckets.Set(toStringFunction)
Creates an empty set.
Method Summary
Method Attributes Method Name and Description
 
add(element)
Adds the specified element to this set if it is not already present.
 
Removes all the elements from this set.
 
contains(element)
Returns true if this set contains the specified element.
 
difference(otherSet)
Performs a difference between this and another set.
 
forEach(callback)
Executes the provided function once per element present in this set.
 
intersection(otherSet)
Performs an intersection between this and another set.
 
Returns true if this set contains no elements.
 
isSubsetOf(otherSet)
Checks whether the given set contains all the elements of this set.
 
remove(element)
Removes the specified element from this set if it is present.
 
size()
Returns the number of elements in this set.
 
Returns an array containing all the elements in this set in arbitrary order.
 
union(otherSet)
Performs a union between this and another set.
Class Detail
buckets.Set(toStringFunction)
Creates an empty set.
Parameters:
{function(Object):string=} toStringFunction
Optional function used to convert elements to unique strings. If the elements aren't strings or if toString() is not appropriate, a custom function which receives a onject and returns a unique string must be provided.
Method Detail
{boolean} add(element)
Adds the specified element to this set if it is not already present.
Parameters:
{Object} element
The element to insert.
Returns:
{boolean} True if this set did not already contain the specified element.

clear()
Removes all the elements from this set.

{boolean} contains(element)
Returns true if this set contains the specified element.
Parameters:
{Object} element
Element to search for.
Returns:
{boolean} True if this set contains the specified element, false otherwise.

difference(otherSet)
Performs a difference between this and another set. Removes from this set all the values that are present in the given set.
Parameters:
{buckets.Set} otherSet
other set.

forEach(callback)
Executes the provided function once per element present in this set.
Parameters:
{function(Object):*} callback
Function to execute, it is invoked with one argument: the element. To break the iteration you can optionally return false inside the callback.

intersection(otherSet)
Performs an intersection between this and another set. Removes all values that are not present in this set and the given set.
Parameters:
{buckets.Set} otherSet
Other set.

{boolean} isEmpty()
Returns true if this set contains no elements.
Returns:
{boolean} True if this set contains no elements.

{boolean} isSubsetOf(otherSet)
Checks whether the given set contains all the elements of this set.
Parameters:
{buckets.Set} otherSet
Other set.
Returns:
{boolean} True if this set is a subset of the given set.

{boolean} remove(element)
Removes the specified element from this set if it is present.
Parameters:
element
Returns:
{boolean} True if this set contained the specified element.

{number} size()
Returns the number of elements in this set.
Returns:
{number} The number of elements in this set.

{Array} toArray()
Returns an array containing all the elements in this set in arbitrary order.
Returns:
{Array} An array containing all the elements in this set.

union(otherSet)
Performs a union between this and another set. Adds all values from the given set to this set.
Parameters:
{buckets.Set} otherSet
Other set.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Sep 17 2014 02:43:23 GMT-0500 (COT)