예제 #1
0
        /// <summary>
        /// 添加一个节点到尾部
        /// </summary>
        /// <param name="pNode"></param>
        /// <returns></returns>
        public DoubleLinkedListNode <T> AddToTail(DoubleLinkedListNode <T> pNode)
        {
            if (pNode == null)
            {
                return(null);
            }

            pNode.next = null;
            if (Tail == null)
            {
                Head = Tail = pNode;
            }
            else
            {
                pNode.prev = Tail;
                pNode.next = pNode;
                Tail       = pNode;
            }
            m_Count++;
            return(Tail);
        }
예제 #2
0
        /// <summary>
        /// 添加一个节点到头部
        /// </summary>
        /// <param name="pNode"></param>
        /// <returns></returns>
        public DoubleLinkedListNode <T> AddToHeader(DoubleLinkedListNode <T> pNode)
        {
            if (pNode == null)
            {
                return(null);
            }

            pNode.prev = null;
            if (Head == null)
            {
                Head = Tail = pNode;
            }
            else
            {
                pNode.next = Head;
                pNode.prev = pNode;
                Head       = pNode;
            }
            m_Count++;
            return(Head);
        }