Exemplo n.º 1
0
 public static void SetNext <T>(this ClassicLinkedList <T> .Node node, ClassicLinkedList <T> .Node target) where T : IComparable <T>
 {
     if (node != null)
     {
         node.Next = target;
     }
 }
Exemplo n.º 2
0
 public static T GetValue <T>(this ClassicLinkedList <T> .Node node) where T : IComparable <T>
 {
     if (node == null)
     {
         return(default(T));
     }
     return((T)node.Value);
 }
Exemplo n.º 3
0
 public static ClassicLinkedList <T> .Node GetNext <T>(this ClassicLinkedList <T> .Node node) where T : IComparable <T>
 {
     if (node == null)
     {
         return(null);
     }
     return(node.Next);
 }
Exemplo n.º 4
0
 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));
 }
Exemplo n.º 5
0
 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;
     }
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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;
            }
        }