Home

Class goog.structs.StringSet

Creates a set of strings.

Instance Method Summary
__iterator__(boolean= opt_keys) ⇒ !goog.iter.Iterator

Returns an iterator that iterates over the elements in the set. NOTE: creating the iterator copies the whole set so use {@link #forEach} when possible.

add(<Any Type> element)

Adds a single element to the set.

addArray(!Array arr)

Adds a the elements of an array to this set.

addDifference_(!goog.structs.StringSet set1, !goog.structs.StringSet set2)

Adds the elements which are in {@code set1} but not in {@code set2} to this set.

addSet(!goog.structs.StringSet stringSet)

Adds a the elements of a set to this set.

clear()

Removes all elements of the set.

clone() ⇒ !goog.structs.StringSet
contains(<Any Type> element) ⇒ boolean

Tells if the set contains the given element.

containsArray(!Array arr) ⇒ boolean

Tells if the set contains all elements of the array.

decode(string key) ⇒ string

Inverse function of {@link #encode}. NOTE: forEach would be 30% faster in FF if the compiler inlined decode.

encode(<Any Type> element) ⇒ <Any Type>

The '__proto__' and the '__count__' keys aren't enumerable in Firefox, and 'toString', 'valueOf', 'constructor', etc. aren't enumerable in IE so they have to be escaped before they are added to the internal object. NOTE: When a new set is created, 50-80% of the CPU time is spent in encode.

equals(!goog.structs.StringSet stringSet) ⇒ boolean

Tells if this set has the same elements as the given set.

forEach(function (string, undefined, goog.structs.StringSet): ? f, ?Object= opt_obj)

Calls a function for each element in the set.

getCount() ⇒ number

Counts the number of elements in the set in linear time. NOTE: getCount is always called at most once per set instance in google3. If this usage pattern won't change, the linear getCount implementation is better, because

  • populating a set and getting the number of elements in it takes the same amount of time as keeping a count_ member up to date and getting its value;
  • if getCount is not called, adding and removing elements have no overhead.

  • getDifference(!goog.structs.StringSet stringSet) ⇒ !goog.structs.StringSet

    Calculates the difference of two sets.

    getIntersection(!goog.structs.StringSet stringSet) ⇒ !goog.structs.StringSet

    Calculates the intersection of this set with another set.

    getSymmetricDifference(!goog.structs.StringSet stringSet) ⇒ !goog.structs.StringSet

    Calculates the symmetric difference of two sets.

    getUnion(!goog.structs.StringSet stringSet) ⇒ !goog.structs.StringSet

    Calculates the union of this set and another set.

    getValues() ⇒ !Array
    isDisjoint(!goog.structs.StringSet stringSet) ⇒ boolean

    Tells if this set and the given set are disjoint.

    isEmpty() ⇒ boolean
    isSubsetOf(!goog.structs.StringSet stringSet) ⇒ boolean

    Tells if this set is the subset of the given set.

    isSupersetOf(!goog.structs.StringSet stringSet) ⇒ boolean

    Tells if this set is the superset of the given set.

    remove(<Any Type> element) ⇒ boolean

    Removes a single element from the set.

    removeArray(!Array arr)

    Removes all elements of the given array from this set.

    removeSet(!goog.structs.StringSet stringSet)

    Removes all elements of the given set from this set.