Beispiel #1
0
        public OneLinkedList(IEnumerable <T> elements)
        {
            OneLinkedListNode <T> newNode;
            OneLinkedListNode <T> prevNode = null;

            foreach (var element in elements)
            {
                newNode = new OneLinkedListNode <T>(element);

                if (prevNode != null)
                {
                    prevNode.NextNode = newNode;
                }
                if (CurrentNode == null)
                {
                    CurrentNode = newNode;
                }
                if (element == elements.Last())
                {
                    newNode.NextNode = CurrentNode;
                }
                prevNode = newNode;
            }
        }
Beispiel #2
0
 public void NextNode()
 {
     CurrentNode = CurrentNode.NextNode;
 }
Beispiel #3
0
 public OneLinkedListNode(T data, OneLinkedListNode <T> nextNode)
 {
     Data     = data;
     NextNode = nextNode;
 }