示例#1
0
        public void InsertAfter(T theElement)
        {
            CNode <T> newNode = new CNode <T>(theElement);

            newNode.Link = current.Link;
            current.Link = newNode;
        }
示例#2
0
        public void ShowList()
        {
            CNode <T> current = header.Link;

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

                current = current.Link;
            }
        }
示例#3
0
        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;
            }
        }
示例#4
0
 public void Reset()
 {
     current  = theList.GetFirst();
     previous = null;
 }
示例#5
0
 public void NextLink()
 {
     previous = current;
     current  = current.Link;
 }
示例#6
0
 public ListIter(CLinkedList <T> list)
 {
     theList  = list;
     current  = theList.GetFirst();
     previous = null;
 }
示例#7
0
 public CLinkedList()
 {
     header = new CNode <T>(default(T));
 }
示例#8
0
 public CNode(T theElement)
 {
     Element = theElement;
     Link    = null;
 }
示例#9
0
 public CNode()
 {
     Element = default(T);
     Link    = null;
 }