Ejemplo n.º 1
0
        /// Inserts a new object after the specified object
        public void Insert(Object newItem, Object after)
        {
            LinkedNode current       = new LinkedNode();
            LinkedNode newLinkedNode = new LinkedNode(newItem);

            current            = Find(after);
            newLinkedNode.Link = current.Link;
            current.Link       = newLinkedNode;
        }
Ejemplo n.º 2
0
        /// Removes an object
        public void Remove(Object n)
        {
            LinkedNode p = FindPrevious(n);

            if (!(p.Link == null))
            {
                p.Link = p.Link.Link;
            }
        }
Ejemplo n.º 3
0
        /// Finds the previous LinkedNode and returns this
        private LinkedNode FindPrevious(Object n)
        {
            LinkedNode current = header;

            while (!(current.Link == null) && (current.Link.Element != n))
            {
                current = current.Link;
            }
            return(current);
        }
Ejemplo n.º 4
0
        /// Prints the LinkedList to Console
        public void PrintList()
        {
            LinkedNode current = new LinkedNode();

            current = header;
            while (!(current.Link == null))
            {
                Console.WriteLine(current.Link.Element);
                current = current.Link;
            }
        }
Ejemplo n.º 5
0
        /// Finds an object in the LinkedList and returns the LinkedNode
        public LinkedNode Find(Object item)
        {
            LinkedNode current = new LinkedNode();

            current = header;

            while (header != item)
            {
                current = current.Link;
            }
            return(current);
        }
Ejemplo n.º 6
0
 /// Resets the iterator
 public void Reset()
 {
     current  = theList.getFirst();
     previous = null;
 }
Ejemplo n.º 7
0
 /// Inserts an object before
 public void InsertBefore(Object theElement)
 {
     LinkedNode newNode = new LinkedNode(theElement);
 }
Ejemplo n.º 8
0
 /// Moves the iterator to the next link
 public void NextLink()
 {
     previous = current;
     current  = current.Link;
 }
Ejemplo n.º 9
0
 /// Constructor for the ListIter
 public ListIter(LinkedList list)
 {
     theList  = list;
     current  = theList.getFirst();
     previous = null;
 }
Ejemplo n.º 10
0
 /// Constructor for LinkedNode accepting an object
 public LinkedNode(Object theElement)
 {
     Element = theElement;
     Link    = null;
 }
Ejemplo n.º 11
0
 /// Constructor for LinkedNode
 public LinkedNode()
 {
     Element = null;
     Link    = null;
 }
Ejemplo n.º 12
0
 /// Constructor for LinkedList
 public LinkedList()
 {
     header = new LinkedNode("header");
 }