Пример #1
0
        public void print()
        {
            DoubleNode tmp = head;

            while (tmp != null)
            {
                Console.WriteLine(tmp.data);
                tmp = tmp.next;
            }
        }
Пример #2
0
        private DoubleNode lastNode(DoubleLinkedList list)
        {
            DoubleNode tmp = list.head;

            while (tmp.next != null)
            {
                tmp = tmp.next;
            }
            return(tmp);
        }
Пример #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;
            }
        }
Пример #4
0
 public DoubleNode(int data)
 {
     this.data = data;
     prev      = null;
     next      = null;
 }