public void AddAfter(LinkedListNode <T> node, LinkedListNode <T> newNode) { VerifyReferencedNode(node); VerifyBlankNode(newNode); newNode.InsertBetween(node, node.forward, this); count++; version++; }
/// <summary>Adds the specified new node after the specified existing node in the <see cref="T:System.Collections.Generic.LinkedList`1" />.</summary> /// <param name="node">The <see cref="T:System.Collections.Generic.LinkedListNode`1" /> after which to insert <paramref name="newNode" />.</param> /// <param name="newNode">The new <see cref="T:System.Collections.Generic.LinkedListNode`1" /> to add to the <see cref="T:System.Collections.Generic.LinkedList`1" />.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="node" /> is null.-or-<paramref name="newNode" /> is null.</exception> /// <exception cref="T:System.InvalidOperationException"> /// <paramref name="node" /> is not in the current <see cref="T:System.Collections.Generic.LinkedList`1" />.-or-<paramref name="newNode" /> belongs to another <see cref="T:System.Collections.Generic.LinkedList`1" />.</exception> public void AddAfter(LinkedListNode <T> node, LinkedListNode <T> newNode) { this.VerifyReferencedNode(node); LinkedList <T> .VerifyBlankNode(newNode); newNode.InsertBetween(node, node.forward, this); this.count += 1u; this.version += 1u; }
/// <summary>Adds the specified new node before the specified existing node in the <see cref="T:System.Collections.Generic.LinkedList`1" />.</summary> /// <param name="node">The <see cref="T:System.Collections.Generic.LinkedListNode`1" /> before which to insert <paramref name="newNode" />.</param> /// <param name="newNode">The new <see cref="T:System.Collections.Generic.LinkedListNode`1" /> to add to the <see cref="T:System.Collections.Generic.LinkedList`1" />.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="node" /> is null.-or-<paramref name="newNode" /> is null.</exception> /// <exception cref="T:System.InvalidOperationException"> /// <paramref name="node" /> is not in the current <see cref="T:System.Collections.Generic.LinkedList`1" />.-or-<paramref name="newNode" /> belongs to another <see cref="T:System.Collections.Generic.LinkedList`1" />.</exception> public void AddBefore(LinkedListNode <T> node, LinkedListNode <T> newNode) { VerifyReferencedNode(node); VerifyBlankNode(newNode); newNode.InsertBetween(node.back, node, this); count++; version++; if (node == first) { first = newNode; } }
/// <summary>Adds the specified new node before the specified existing node in the <see cref="T:System.Collections.Generic.LinkedList`1" />.</summary> /// <param name="node">The <see cref="T:System.Collections.Generic.LinkedListNode`1" /> before which to insert <paramref name="newNode" />.</param> /// <param name="newNode">The new <see cref="T:System.Collections.Generic.LinkedListNode`1" /> to add to the <see cref="T:System.Collections.Generic.LinkedList`1" />.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="node" /> is null.-or-<paramref name="newNode" /> is null.</exception> /// <exception cref="T:System.InvalidOperationException"> /// <paramref name="node" /> is not in the current <see cref="T:System.Collections.Generic.LinkedList`1" />.-or-<paramref name="newNode" /> belongs to another <see cref="T:System.Collections.Generic.LinkedList`1" />.</exception> public void AddBefore(LinkedListNode <T> node, LinkedListNode <T> newNode) { this.VerifyReferencedNode(node); LinkedList <T> .VerifyBlankNode(newNode); newNode.InsertBetween(node.back, node, this); this.count += 1u; this.version += 1u; if (node == this.first) { this.first = newNode; } }
public void AddLast(LinkedListNode <T> node) { VerifyBlankNode(node); if (first == null) { node.SelfReference(this); first = node; } else { node.InsertBetween(first.back, first, this); } count++; version++; }
/// <summary>Adds the specified new node at the end of the <see cref="T:System.Collections.Generic.LinkedList`1" />.</summary> /// <param name="node">The new <see cref="T:System.Collections.Generic.LinkedListNode`1" /> to add at the end of the <see cref="T:System.Collections.Generic.LinkedList`1" />.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="node" /> is null.</exception> /// <exception cref="T:System.InvalidOperationException"> /// <paramref name="node" /> belongs to another <see cref="T:System.Collections.Generic.LinkedList`1" />.</exception> public void AddLast(LinkedListNode <T> node) { LinkedList <T> .VerifyBlankNode(node); if (this.first == null) { node.SelfReference(this); this.first = node; } else { node.InsertBetween(this.first.back, this.first, this); } this.count += 1u; this.version += 1u; }