Esempio n. 1
0
        // 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;
        }
Esempio n. 2
0
        // write contenst of list to console
        public void ShowList()
        {
            CNode <T> current = header.Link;

            while (!(current == null))
            {
                Console.WriteLine(current.Element);

                current = current.Link;
            }
        }
Esempio n. 3
0
        // 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;
            }
        }
Esempio n. 4
0
 // resets iterator
 public void Reset()
 {
     current  = theList.GetFirst();
     previous = null;
 }
Esempio n. 5
0
 // goes to next node
 // current node becomes previous
 // next node becomes current node
 public void NextLink()
 {
     previous = current;
     current  = current.Link;
 }
Esempio n. 6
0
 // new iterator
 // parameter list linkedlist for iterator
 public ListIter(CLinkedList <T> list)
 {
     theList  = list;
     current  = theList.GetFirst();
     previous = null;
 }
Esempio n. 7
0
 public CNode(T theElement)
 {
     Element = theElement;
     Link    = null;
 }
Esempio n. 8
0
 public CNode()
 {
     Element = default(T);
     Link    = null;
 }
Esempio n. 9
0
 // new Clinkedlist
 public CLinkedList()
 {
     header = new CNode <T>(default(T));
 }