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