コード例 #1
0
        /// <summary>
        /// 移除所有节点;
        /// </summary>
        public void Clear()
        {
            DoublyLinkedListNode <T> current = First;

            while (current != null)
            {
                DoublyLinkedListNode <T> temp = current;
                current = current.Next;
                temp.Invalidate();
            }
            First = null;
            Last  = null;
            Count = 0;
        }
コード例 #2
0
        /// <summary>
        /// 移除这个节点之前的所有节点;
        /// </summary>
        public void RemoveBeforNodes(DoublyLinkedListNode <T> node)
        {
            ValidateNode(node);
            DoublyLinkedListNode <T> current = node.Previous;

            while (current != null)
            {
                DoublyLinkedListNode <T> temp = current;
                current = current.Previous;
                temp.Invalidate();
                Count--;
            }
            node.Previous = null;
            First         = node;
        }
コード例 #3
0
        /// <summary>
        /// 移除这个节点之后的所有节点;
        /// </summary>
        public void RemoveAfterNodes(DoublyLinkedListNode <T> node)
        {
            ValidateNode(node);
            DoublyLinkedListNode <T> current = node.Next;

            while (current != null)
            {
                DoublyLinkedListNode <T> temp = current;
                current = current.Next;
                temp.Invalidate();
                Count--;
            }
            node.Next = null;
            Last      = node;
        }
コード例 #4
0
        private void InternalRemoveNode(DoublyLinkedListNode <T> node)
        {
            if (node.Next == null)
            {
                Last = node.Previous;
            }
            else
            {
                node.Next.Previous = node.Previous;
            }

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

            node.Invalidate();
            Count--;
            version++;
        }