WeakCollection<'T> Type

A collection that allows its elements to be garbage-collected (unless there are other references to the elements). Elements will disappear from the collection when they are garbage-collected. The WeakCollection is not thread-safe, not even for read-only access! No methods may be called on the WeakCollection while it is enumerated, not even a Contains or creating a second enumerator. The WeakCollection does not preserve any order among its contents; the ordering may be different each time the collection is enumerated. Since items may disappear at any time when they are garbage collected, this class cannot provide a useful implementation for Count and thus cannot implement the ICollection interface.

Constructors

Constructor Description

WeakCollection()

Full Usage: WeakCollection()

Instance members

Instance member Description

this.Add

Full Usage: this.Add

Parameters:
    item : 'T

Adds an element to the collection. Runtime: O(n).

item : 'T

this.Clear

Full Usage: this.Clear

Removes all elements from the collection. Runtime: O(n).

this.Remove

Full Usage: this.Remove

Parameters:
    item : 'T

Returns: bool

Removes an element from the collection. Returns true if the item is found and removed, false when the item is not found. Runtime: O(n).

item : 'T
Returns: bool