// insert new node after current node public void InsertAfter(T theElement) { CNode <T> newNode = new CNode <T>(theElement); newNode.Link = current.Link; current.Link = newNode; }
// write contenst of list to console public void ShowList() { CNode <T> current = header.Link; while (!(current == null)) { Console.WriteLine(current.Element); current = current.Link; } }
// insert new node before current node public void InsertBefore(T theElement) { CNode <T> newNode = new CNode <T>(theElement); if (previous.Link == null) { throw new InsertBeforeHeaderException("Can't insert here."); } else { newNode.Link = previous.Link; previous.Link = newNode; current = newNode; } }
// resets iterator public void Reset() { current = theList.GetFirst(); previous = null; }
// goes to next node // current node becomes previous // next node becomes current node public void NextLink() { previous = current; current = current.Link; }
// new iterator // parameter list linkedlist for iterator public ListIter(CLinkedList <T> list) { theList = list; current = theList.GetFirst(); previous = null; }
public CNode(T theElement) { Element = theElement; Link = null; }
public CNode() { Element = default(T); Link = null; }
// new Clinkedlist public CLinkedList() { header = new CNode <T>(default(T)); }