Set<T> class
NOTE: For 2.0 the #constructor argument has changed. Set now optionally accepts a collection, and only checks types in TypeScript.
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:
var set = new go.Set(); // In TypeScript: new go.Set<string>();
set.add("orange");
set.add("apple");
set.add("orange");
// now set.count === 2
// and set.contains("orange") === true
// and set.contains("banana") === false
You can iterate over the items in a Set:
var it = aSet.iterator;
while (it.next()) {
. . . it.value . . .
}
Or:
aSet.each(val => {
. . . val . . .
});
Although not precisely implementing the features of the EcmaScript 6 Set class, this GoJS Set class has synonyms for the following methods and property:
- add(val): #add
- delete(val): #remove
- has(val): #contains
- clear(): #clear
- size: #count
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 ES6 iteration, so that functionality has not been made somewhat compatible. These collection classes were defined in GoJS before the ES6 collection classes were proposed.
- Implemented types
-
- Iterable<
T>
- Iterable<
- Available extensions
- Annotations
-
- @JS()
- @staticInterop
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
hashId(
Object obj) → num? - (undocumented) Get the unique hash ID for an object; may return undefined.
-
hashIdUnique(
Object obj) → num - (undocumented) Get the unique hash ID for an object, making it if necessary.
-
uniqueHash(
Object obj) → void - (undocumented) Set the unique hash ID for an object. This should be called at the beginning of each constructor that does not inherit from another class.