Cadenza : Cadenza.Collections Namespace

LinkedListCoda Class

LinkedList<T> extension methods.

public static class LinkedListCoda

Remarks

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Members

See Also: Inherited members from object.

Public Methods

static
NodeAt<T> (this LinkedList<T>, int) : LinkedListNode<T>
Returns the LinkedListNode<T> at the specified index of the LinkedList<T>.

Member Details

NodeAt<T> Generic Method

Returns the LinkedListNode<T> at the specified index of the LinkedList<T>.

public static LinkedListNode<T> NodeAt<T> (this LinkedList<T> self, int index)

Type Parameters

T
The type of the elements within self.

Parameters

self
A LinkedList<T> to get a LinkedListNode<T> from.
index
A int containing the zero-based index of the LinkedListNode<T> to retrieve.

Returns

The LinkedListNode<T> at the specified index of the LinkedList<T>.

Exceptions

Type Reason
ArgumentNullException self is null.
ArgumentOutOfRangeException

index is negative.

-or-

index is greater than or equal to LinkedList<T>.Count.

Remarks

C# Example
LinkedList<int> list = new LinkedList<int>();
list.AddLast (1); // first node;  index=0
list.AddLast (2); // middle node; index=1
list.AddLast (3); // last node;   index=2

Assert.AreSame (list.First,         list.NodeAt (0));
Assert.AreSame (list.First.Next,    list.NodeAt (1));
Assert.AreSame (list.Last.Previous, list.NodeAt (1));
Assert.AreSame (list.Last,          list.NodeAt (2));
Assert.AreEqual (3, list.NodeAt (2).Value);

Requirements

Namespace: Cadenza.Collections
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0