There are two possible constructors:
new go.Set()
, for JavaScript
new go.Set<T>()
for TypeScript
In TypeScript, the optional generic argument describes the type of values that this Set may hold.
For example, the expression:
// TypeScript:
new go.Set<go.Point>()
Creates a new Set that may only contain Points.
Optional
coll: Iterable<T> | T[]an optional collection of items to add.
Readonly
countThis read-only property is the number of elements in the Set.
Readonly
iteratorGets an object that you can use for iterating over the Set. The value will be a member of the Set. Typical usage:
const it = aSet.iterator;
while (it.next()) {
. . . " value: " + it.value . . .
}
Readonly
sizeThis read-only property is the number of elements in the Set.
Virtual
allThis 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.
Virtual
anyThis 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.
Virtual
copyVirtual
eachCall a provided function once per each key/value pair in this Set.
a function to call for each value in the Set
a value to use as this when executing callbackFunc
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.