Method AddBefore
AddBefore(Node, T, bool)
Adds a value before the specified node.
Declaration
public WeakList<T>.Node? AddBefore(WeakList<T>.Node currentNode, T value, bool allowBeforeRemovedNode)
Parameters
| Type | Name | Description |
|---|---|---|
| WeakList<T>.Node | currentNode | The node to add the value before. |
| T | value | The value to add. |
| bool | allowBeforeRemovedNode | true to add the value near the position that |
Returns
| Type | Description |
|---|---|
| WeakList<T>.Node | The node that was added, or null if |
Remarks
This operation takes O(1) time unless currentNode has been removed from the list, in which case the list is searched backwards
from its former position for the nearest node that is still present and the value is added after that node.
Values added relative to a node that has been removed may end up in a different relative order than they would have had if the node were still in the list.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| InvalidOperationException |
|
| ObjectDisposedException | The list has been disposed. |
AddBefore(Node, T)
Adds a value before the specified node, or near the position the node occupied if it has been removed from the list.
Declaration
public WeakList<T>.Node AddBefore(WeakList<T>.Node currentNode, T value)
Parameters
| Type | Name | Description |
|---|---|---|
| WeakList<T>.Node | currentNode | The node to add the value before. |
| T | value | The value to add. |
Returns
| Type | Description |
|---|---|
| WeakList<T>.Node | The node that was added. |
Remarks
This operation takes O(1) time unless currentNode has been removed from the list, in which case the list is searched backwards
from its former position for the nearest node that is still present and the value is added after that node.
Values added relative to a node that has been removed may end up in a different relative order than they would have had if the node were still in the list.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| InvalidOperationException |
|
| ObjectDisposedException | The list has been disposed. |