예제 #1
0
        public DoublyLinkedListNode <T> AddLast(T value)
        {
            DoublyLinkedListNode <T> node = new DoublyLinkedListNode <T>(value);

            if (IsEmpty)
            {
                First = node;
            }
            else
            {
                node.Previous = Last;
                Last.Next     = node;
            }

            Last = node;

            Count++;

            return(node);
        }
예제 #2
0
        public void AddLast(DoublyLinkedListNode <T> node)
        {
            if (Count == 0)
            {
                Head = node;
            }

            else
            {
                Tail.Next = node;

                // Before: Head -> 3 <-> 5 -> null
                // After:  Head -> 3 <-> 5 <-> 7 -> null
                // 7.Previous = 5
                node.Previous = Tail;
            }

            Tail = node;
            Count++;
        }
예제 #3
0
 public void Clear()
 {
     First = null;
     Last  = null;
     Count = 0;
 }