Esempio n. 1
0
        // 清空列表
        public void Clear()
        {
            LinkNode <T> cur = head.next;

            head.Reset();

            while (cur != null)
            {
                LinkNode <T> toClear = cur;
                cur = cur.next;

                toClear.Reset();
            }

            length = 0;
        }
Esempio n. 2
0
        // 删除元素
        public override bool Delete(int index)
        {
            if (index < 0 || index > length - 1)
            {
                LogError("Out of the range!");
                return(false);
            }

            LinkNode <T> lastNode = GetLastNode(index);
            LinkNode <T> node     = lastNode.next;

            lastNode.next = node.next;

            node.Reset();
            length--;

            return(true);
        }