示例#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;
            }
        }
示例#2
0
 public void NextNode()
 {
     CurrentNode = CurrentNode.NextNode;
 }
示例#3
0
 public OneLinkedListNode(T data, OneLinkedListNode <T> nextNode)
 {
     Data     = data;
     NextNode = nextNode;
 }