Пример #1
0
 private void free(MyDuLinkNode <T> p)
 {
     p.Next  = null;
     p.Prior = null;
     p.Data  = default(T);
     p       = null;
 }
Пример #2
0
        private MyDuLinkNode <T> InternalInsert(MyDuLinkNode <T> p, T data)
        {
            var newNode = new MyDuLinkNode <T>(data);

            newNode.Next  = p.Next;
            newNode.Prior = p;
            p.Next.Prior  = newNode;
            p.Next        = newNode;

            Length++;

            return(newNode);
        }
Пример #3
0
        public void ClearList()
        {
            // 不改变L
            // 初始条件:L已存在。操作结果:将L重置为空表
            MyDuLinkNode <T> q, p = Head.Next;

            while (p != null)
            {
                q = p.Next;
                free(p);
                p = q;
            }

            Head.Next = Head.Prior = Head; //收尾均指向自身
            Length    = 0;
        }
Пример #4
0
        public void DestroyList()
        {
            // 操作结果:销毁双向循环链表L
            MyDuLinkNode <T> q, p = Head.Next; // p指向第一个结点

            while (p != Head)
            {
                // p没到表头
                q = p.Next;
                free(p);
                p = q;
            }

            Length = 0;
            free(Head);
        }
Пример #5
0
 public MyDuLinkList()
 {
     Head      = new MyDuLinkNode <T>(); //头节点不存数据
     Head.Next = Head.Prior = Head;
     Length    = 0;
 }