Method GetEnumerator
GetEnumerator()
Returns an enumerator that iterates through the values in the list.
Declaration
public WeakList<T>.Enumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| WeakList<T>.Enumerator |
Remarks
Nodes whose values have been garbage collected are skipped, so the enumerator never returns null. Use GetNodeEnumerator() to enumerate nodes instead of values.
Nodes added by other threads while enumerating may be included depending on timing. Use WasAddedDuringEnumeration to detect them, or AsEnumerable(bool, bool) to skip them.
Enumerating the entire list takes O(n) time. Each step takes O(1) time unless the current node was removed by another thread, in which case the enumerator searches forward for the next node that is still present.
GetEnumerator(Node)
Returns an enumerator that iterates through the values in the list starting from the position of the specified node.
Declaration
public WeakList<T>.Enumerator GetEnumerator(WeakList<T>.Node startNode)
Parameters
| Type | Name | Description |
|---|---|---|
| WeakList<T>.Node | startNode |
Returns
| Type | Description |
|---|---|
| WeakList<T>.Enumerator |
Remarks
startNode itself is not included in the enumeration. The first call to MoveNext() moves to the value
after it and the first call to MovePrevious() moves to the value before it.
Nodes whose values have been garbage collected are skipped, so the enumerator never returns null. Use GetNodeEnumerator() to enumerate nodes instead of values.
Nodes added by other threads while enumerating may be included depending on timing. Use WasAddedDuringEnumeration to detect them, or AsEnumerable(bool, bool) to skip them.
Enumerating the entire list takes O(n) time. Each step takes O(1) time unless the current node was removed by another thread, in which case the enumerator searches forward for the next node that is still present.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException |
|