documentationfor yFiles for HTML 2.6

ICollection<T>

Defines methods to manipulate a collection of objects with the same type.

Remarks

This interface is similar in functionality to the native Array, but does not provide an inherent index-based access. It's a convertible type that can be used in the following alternative ways in parameter lists, parameter objects or setters when annotated as such:

It is possible to specify an Array or to use the native 'iterable' protocol, iterators, or generators to populate the ICollection<T> instance:

// Array
object.property = [item1, item2]

// Iterables
object.property = new Set([item1, item2])
object.property = new Map([
  [key1, item1],
  [key2, item2]
]).entries()

// Generators
function* generator(i) {
  yield i
  yield i + 10
}

// via the iterator protocol (with invocation)
object.property = generator(10)

// via the generator function (will be executed immediately to populate the collection)
object.property = function* generateValues() {
  yield 1
  yield 2
}// Array
object.property = [item1, item2]

// Iterables
object.property = new Set([item1, item2])
object.property = new Map([
  [key1, item1],
  [key2, item2]
]).entries()

// Generators
function* generator(i: number) {
  yield i
  yield i + 10
}

// via the iterator protocol (with invocation)
object.property = generator(10)

// via the generator function (will be executed immediately to populate the collection)
object.property = function* generateValues() {
  yield 1
  yield 2
}

Note that when using native iterables, in contrast to IEnumerable<T> created with from which will reevaluate upon re-enumeration, the collection will be populated only once, when when created with from, and thus the generator will only be executed once.

Type Parameters

T
The type of the elements in the collection.

Type Details

yfiles module
core
yfiles-umd modules
All modules
Legacy UMD name
yfiles.collections.ICollection

See Also

Properties

Methods

Static Methods