ReadonlycountThis read-only property is the number of elements in the Set.
ReadonlyiteratorReadonlysizeThis read-only property is the number of elements in the Set.
This class implements the JavaScript Symbol.iterator,
and can be used with spread syntax or for ... of statements.
since3.0
Adds a given value to the Set, if not already present.
Be careful not to call this method while iterating over the collection.
The value to add to the Set; must not be null.
This modified Set.
Adds all of the values of a collection to this Set.
Be careful not to call this method while iterating over the collection.
This modified Set.
VirtualallThis is true if all invocations of the given predicate on items in the collection are true.
Call the given predicate on each item in the collection. As soon as a call returns false, this returns false. Otherwise this returns true. For an empty collection this returns true.
This function must not have any side-effects.
True if all predicate calls are true; false otherwise.
VirtualanyThis is true if any invocation of the given predicate on items in the collection is true.
Call the given predicate on each item in the collection. As soon as a call returns true, this returns true. Otherwise this returns false. For an empty collection this returns false.
This function must not have any side-effects.
True if any predicate call is true; false otherwise.
Clears the Set. This sets the count to zero.
Be careful not to call this method while iterating over the collection.
VirtualcopyRemoves a value (if found) from the Set.
Be careful not to call this method while iterating over the collection.
The value to remove.
true if the value was found and removed, false otherwise.
VirtualeachCall the given function on each item in the collection.
This function must not modify the collection.
This Set itself.
Returns the first item in the collection, or null if there is none.
This returns null if there are no items in the collection.
Returns whether the given value is in this Set.
The value to check.
Whether or not the value is contained within the Set.
Produces a JavaScript Array from the contents of this Set.
A copy of the Set in Array form.
An unordered iterable collection that cannot contain two instances of the same value. In TypeScript it is a generic class that enforces at compile-time the type of elements that may be added to the Set.
An example usage:
You can iterate over the items in a Set:
Or:
For compatibility with versions of GoJS before version 3.0, the following synonyms are defined:
The constructor now takes an optional Iterable or Array argument that provides the initial elements for the new Set.
Note that GoJS iteration is quite different than ECMAScript iteration, so that functionality has not been made somewhat compatible. These collection classes were defined in GoJS before the ECMAScript collection classes were proposed.