public static void SetNext <T>(this ClassicLinkedList <T> .Node node, ClassicLinkedList <T> .Node target) where T : IComparable <T> { if (node != null) { node.Next = target; } }
public static T GetValue <T>(this ClassicLinkedList <T> .Node node) where T : IComparable <T> { if (node == null) { return(default(T)); } return((T)node.Value); }
public static ClassicLinkedList <T> .Node GetNext <T>(this ClassicLinkedList <T> .Node node) where T : IComparable <T> { if (node == null) { return(null); } return(node.Next); }
public static ClassicLinkedList <T> .Node Seek <T>(this ClassicLinkedList <T> list, int index) where T : IComparable <T> { if (index < 0 || index >= list.Count) { return(null); } return(list.Head.Skip(index)); }
public static void ForEach <T>(this ClassicLinkedList <T> list, Action <T> action) where T : IComparable <T> { ClassicLinkedList <T> .Node curr = list.Head; while (curr != null) { action(curr.Value); curr = curr.Next; } }
public static ClassicLinkedList <T> .Node Skip <T>(this ClassicLinkedList <T> .Node node, int count) where T : IComparable <T> { var nx = node; int i = 0; while (i++ < count && nx != null) { nx = nx.Next; } return(nx); }
public static void DumpNodes <T>(this ClassicLinkedList <T> list) where T : IComparable <T> { if (list == null) { Console.WriteLine("LinkedList<T> DumpNodes: list is null."); } ClassicLinkedList <T> .Node tempNode = list.Head; while (tempNode != null) { Console.WriteLine(tempNode.Value); tempNode = tempNode.Next; } }