Esempio n. 1
0
        public void print()
        {
            DoubleNode tmp = head;

            while (tmp != null)
            {
                Console.WriteLine(tmp.data);
                tmp = tmp.next;
            }
        }
Esempio n. 2
0
        private DoubleNode lastNode(DoubleLinkedList list)
        {
            DoubleNode tmp = list.head;

            while (tmp.next != null)
            {
                tmp = tmp.next;
            }
            return(tmp);
        }
Esempio n. 3
0
        public void insert(int data)
        {
            DoubleLinkedList list    = this;
            DoubleNode       newNode = new DoubleNode(data);

            if (list.head == null)
            {
                newNode.prev = null;
                list.head    = newNode;
                return;
            }
            else
            {
                DoubleNode prevNode = lastNode(list);
                prevNode.next = newNode;
                newNode.prev  = prevNode;
            }
        }
Esempio n. 4
0
 public DoubleNode(int data)
 {
     this.data = data;
     prev      = null;
     next      = null;
 }