Beispiel #1
0
        public DoubleNode GetLastNode(DoubleNode doublyList)
        {
            DoubleNode temp = headNode;

            while (temp.next != null)
            {
                temp = temp.next;
            }
            return(temp);
        }
Beispiel #2
0
        public void AddToEnd(string data)
        {
            var newNode = new DoubleNode(data);

            if (headNode == null)
            {
                headNode = newNode;
                return;
            }
            var lastNode = GetLastNode(this.headNode);

            lastNode.next    = newNode;
            newNode.previous = lastNode;
        }
Beispiel #3
0
        public void AddToBeginning(string data)
        {
            var newNode = new DoubleNode(data);

            newNode.next     = headNode;
            newNode.previous = null;

            if (headNode != null)
            {
                headNode.previous = headNode;
            }

            headNode = newNode;
        }
Beispiel #4
0
 public DoublyLinkedList()
 {
     headNode = null;
 }
 public DoubleNode(string a)
 {
     data     = a;
     next     = null;
     previous = null;
 }