List<T> class
NOTE: For 2.0 the #constructor argument has changed. List now optionally accepts a collection, and only checks types in TypeScript.
An ordered iterable collection. In TypeScript it is a generic class that enforces at compile-time the type of elements that may be added to the List.
An example usage:
var list = new go.List(); // or in TypeScript: new go.List<go.Point>();
list.add(new go.Point(0, 0));
list.add(new go.Point(20, 10));
list.add(new go.Point(10, 20));
// now list.length === 3
// and list.elt(1) instanceof go.Point
You can iterate over the items in a List:
var it = aList.iterator;
while (it.next()) {
console.log("#" + it.key + " is " + it.value);
}
Or:
aList.each(val => {
console.log(val);
});
The key will range from zero to #count-1.
For convenience this GoJS List class has synonyms for the following methods and property:
- get(idx): #elt
- set(idx,val): #setElt
- has(val): #contains
- delete(val): #remove
- clear(): #clear
- size: #count
The constructor now takes an optional Iterable or Array argument that provides the initial elements for the new List.
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