Ejemplo n.º 1
0
 public void TraverseBack(DBLinkedList node)
 {
     if (node == null)
     {
         node = this;
     }
     System.Console.WriteLine("\n\nTraversing in Backward Direction\n\n");
     while (node != null)
     {
         System.Console.WriteLine(node.data);
         node = node.prev;
     }
 }
Ejemplo n.º 2
0
 public void TraverseFront(DBLinkedList node)
 {
     if (node == null)
     {
         node = this;
     }
     System.Console.WriteLine("\n\nTraversing in Forward Direction\n\n");
     while (node != null)
     {
         System.Console.WriteLine(node.data);
         node = node.next;
     }
 }
Ejemplo n.º 3
0
        public DBLinkedList InsertPrev(string value)
        {
            DBLinkedList node = new DBLinkedList(value);

            if (this.prev == null)
            {
                node.prev = null; // already set on constructor
                node.next = this;
                this.prev = node;
            }
            else
            {
                // Insert in the middle
                DBLinkedList temp = this.prev;
                node.prev = temp;
                node.next = this;
                this.prev = node;
                temp.next = node;
                // temp.prev does not have to be changed
            }
            return(node);
        }
Ejemplo n.º 4
0
        public DBLinkedList InsertNext(string value)
        {
            DBLinkedList node = new DBLinkedList(value);

            if (this.next == null)
            {
                // Easy to handle
                node.prev = this;
                node.next = null; // already set in constructor
                this.next = node;
            }
            else
            {
                // Insert in the middle
                DBLinkedList temp = this.next;
                node.prev = this;
                node.next = temp;
                this.next = node;
                temp.prev = node;
                // temp.next does not have to be changed
            }
            return(node);
        }
Ejemplo n.º 5
0
 public DBLinkedList(string value)
 {
     data = value;
     next = null;
     prev = null;
 }
Ejemplo n.º 6
0
 public DBLinkedList()
 {
     data = "";
     next = null;
     prev = null;
 }