goog.structs.Set
Classgoog.structs.Set(opt_values)
A set that can contain both primitives and objects. Adding and removing elements is O(1). Primitives are treated as identical if they have the same type and convert to the same string. Objects are treated as identical only if they are references to the same object. WARNING: A goog.structs.Set can contain both 1 and (new Number(1)), because they are not the same. WARNING: Adding (new Number(1)) twice will yield two distinct elements, because they are two different objects. WARNING: Any object that is added to a goog.structs.Set will be modified! Because goog.getUid() is used to identify objects, every object in the set will be mutated.
opt_values
{Array
|Object
=}
.__iterator__(opt_keys)
Returns an iterator that iterates over the elements in this set.
opt_keys
{boolean
=}
goog.iter.Iterator
}
.add(element)
Add a primitive or an object to the set.
element
{*}
.addAll(col)
Adds all the values in the given collection to this set.
col
{Array
|Object
}
.clear()
Removes all elements from this set.
.clone()
Creates a shallow clone of this set.
goog.structs.Set
}
.contains(element)
Tests whether this set contains the given element.
element
{*}
boolean
}
.containsAll(col)
Tests whether this set contains all the values in a given collection. Repeated elements in the collection are ignored, e.g. (new goog.structs.Set([1, 2])).containsAll([1, 1]) is True.
col
{Object
}
boolean
}
.difference(col)
Finds all values that are present in this set and not in the given collection.
col
{Array
|Object
}
goog.structs.Set
}
.equals(col)
Tests whether the given collection consists of the same elements as this set, regardless of order, without repetition. Primitives are treated as equal if they have the same type and convert to the same string; objects are treated as equal if they are references to the same object. This operation is O(n).
col
{Object
}
boolean
}
.getCount()
number
}
.getValues()
Returns an array containing all the elements in this set.
Array
}
.intersection(col)
Finds all values that are present in both this set and the given collection.
col
{Array
|Object
}
goog.structs.Set
}
.isEmpty()
Tests whether this set is empty.
boolean
}
.isSubsetOf(col)
Tests whether the given collection contains all the elements in this set. Primitives are treated as equal if they have the same type and convert to the same string; objects are treated as equal if they are references to the same object. This operation is O(n).
col
{Object
}
boolean
}
.remove(element)
Removes the given element from this set.
element
{*}
boolean
}
.removeAll(col)
Removes all values in the given collection from this set.
col
{Array
|Object
}