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

            while (temp.next != null)
            {
                temp = temp.next;
            }
            return(temp);
        }
示例#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;
        }
示例#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;
        }
示例#4
0
 public DoublyLinkedList()
 {
     headNode = null;
 }
 public DoubleNode(string a)
 {
     data     = a;
     next     = null;
     previous = null;
 }