LinkedList<T>.AddAfter Method

Definition

Adds a new node or value after an existing node in the LinkedList<T>.

Overloads

AddAfter(LinkedListNode<T>, LinkedListNode<T>)

Adds the specified new node after the specified existing node in the LinkedList<T>.

AddAfter(LinkedListNode<T>, T)

Adds a new node containing the specified value after the specified existing node in the LinkedList<T>.

AddAfter(LinkedListNode<T>, LinkedListNode<T>)

Adds the specified new node after the specified existing node in the LinkedList<T>.

public:
 void AddAfter(System::Collections::Generic::LinkedListNode<T> ^ node, System::Collections::Generic::LinkedListNode<T> ^ newNode);
public void AddAfter (System.Collections.Generic.LinkedListNode<T> node, System.Collections.Generic.LinkedListNode<T> newNode);
member this.AddAfter : System.Collections.Generic.LinkedListNode<'T> * System.Collections.Generic.LinkedListNode<'T> -> unit
Public Sub AddAfter (node As LinkedListNode(Of T), newNode As LinkedListNode(Of T))

Parameters

node
LinkedListNode<T>

The LinkedListNode<T> after which to insert newNode.

newNode
LinkedListNode<T>

The new LinkedListNode<T> to add to the LinkedList<T>.

Exceptions

node is null.

-or-

newNode is null.

node is not in the current LinkedList<T>.

-or-

newNode belongs to another LinkedList<T>.

Examples

For an example that includes this method, see the LinkedList<T> class.

Remarks

LinkedList<T> accepts null as a valid Value for reference types and allows duplicate values.

This method is an O(1) operation.

See also

Applies to

AddAfter(LinkedListNode<T>, T)

Adds a new node containing the specified value after the specified existing node in the LinkedList<T>.

public:
 System::Collections::Generic::LinkedListNode<T> ^ AddAfter(System::Collections::Generic::LinkedListNode<T> ^ node, T value);
public System.Collections.Generic.LinkedListNode<T> AddAfter (System.Collections.Generic.LinkedListNode<T> node, T value);
member this.AddAfter : System.Collections.Generic.LinkedListNode<'T> * 'T -> System.Collections.Generic.LinkedListNode<'T>
Public Function AddAfter (node As LinkedListNode(Of T), value As T) As LinkedListNode(Of T)

Parameters

node
LinkedListNode<T>

The LinkedListNode<T> after which to insert a new LinkedListNode<T> containing value.

value
T

The value to add to the LinkedList<T>.

Returns

The new LinkedListNode<T> containing value.

Exceptions

node is null.

node is not in the current LinkedList<T>.

Examples

For an example that includes this method, see the LinkedList<T> class.

Remarks

LinkedList<T> accepts null as a valid Value for reference types and allows duplicate values.

This method is an O(1) operation.

See also

Applies to