Exemplo n.º 1
0
        // Adds this element to the list, with replacing the specified element.
        // This is equivalent to calling the sequence: LinkBefore(Replace); replace.Unlink();
        public void LinkReplace(DoubleLinkBaseAdv <T> link, DoubleLinkBaseAdv <T> replace)
        {
            Debug.Assert(link != null);
            Debug.Assert(replace != null);
            Debug.Assert(replace.List == this);

            if (link.IsLinked)
            {
                link.Unlink();
            }

            link.Previous = replace.Previous;
            link.Next     = replace.Next;

            if (link.Previous != null)
            {
                link.Previous.Next = link;
            }

            if (link.Next != null)
            {
                link.Next.Previous = link;
            }

            replace.Next     = null;
            replace.Previous = null;
        }
Exemplo n.º 2
0
 // Remove link from list
 public void Unlink()
 {
     if (Next != null)
     {
         Next.Previous = Previous;
     }
     if (Previous != null)
     {
         Previous.Next = Next;
     }
     Next = Previous = null;
 }
Exemplo n.º 3
0
        // Adds this element to the list, after the specified element
        public void LinkAfter(DoubleLinkBaseAdv <T> link, DoubleLinkBaseAdv <T> after)
        {
            Debug.Assert(link != null);
            Debug.Assert(after != null);
            Debug.Assert(after.List == this);

            if (link.IsLinked)
            {
                link.Unlink();
            }

            link.List     = this;
            link.Next     = after.Next;
            after.Next    = link;
            link.Previous = after;
            if (link.Next != null)
            {
                link.Next.Previous = link;
            }
            count++;
        }
Exemplo n.º 4
0
        // Adds this element to a list, before the given element.
        public void LinkBefore(DoubleLinkBaseAdv <T> link, DoubleLinkBaseAdv <T> before)
        {
            Debug.Assert(link != null);
            Debug.Assert(before != null);
            Debug.Assert(before.List == this);

            if (link.IsLinked)
            {
                link.Unlink();
            }

            link.List       = this;
            link.Previous   = before.Previous;
            before.Previous = link;
            link.Next       = before;
            if (link.Previous != null)
            {
                link.Previous.Next = link;
            }
            count++;
        }
Exemplo n.º 5
0
        // Remove link from list
        public void Unlink(DoubleLinkBaseAdv <T> link)
        {
            Debug.Assert(link != null);
            Debug.Assert(link.List != this);

            if (link.IsLinked)
            {
                link.Unlink();
            }

            link.List = this;
            if (link.Next != null)
            {
                link.Next.Previous = link.Previous;
            }
            if (link.Previous != null)
            {
                link.Previous.Next = link.Next;
            }
            link.Next = link.Previous = null;
            link.List = null;
            count--;
        }
Exemplo n.º 6
0
 // Adds this element to the list, with replacing the specified element.
 // This is equivalent to calling the sequence: LinkBefore(Replace); replace.Unlink();
 public void LinkReplace(DoubleLinkBaseAdv <T> replace)
 {
     Debug.Assert(replace != null);
     Debug.Assert(List != null);
     List.LinkReplace(this, replace);
 }
Exemplo n.º 7
0
 // Adds this element to the list, after the specified element
 public void LinkAfter(DoubleLinkBaseAdv <T> after)
 {
     Debug.Assert(after != null);
     Debug.Assert(List != null);
     List.LinkAfter(this, after);
 }
Exemplo n.º 8
0
 // Adds this element to a list, before the given element.
 public void LinkBefore(DoubleLinkBaseAdv <T> before)
 {
     Debug.Assert(before != null);
     Debug.Assert(List != null);
     List.LinkBefore(this, before);
 }
Exemplo n.º 9
0
 // Create link without connection to the list
 public DoubleLinkBaseAdv(T data = null)
 {
     Data     = data;
     Next     = null;
     Previous = null;
 }
Exemplo n.º 10
0
 public void AddFirst(DoubleLinkBaseAdv <T> link)
 {
     LinkAfter(link, Last);
 }
Exemplo n.º 11
0
 public void AddLast(DoubleLinkBaseAdv <T> link)
 {
     LinkBefore(link, First);
 }
Exemplo n.º 12
0
 // Construct empty list
 public DoubleLinkedListAdv()
 {
     First = Last = Root; count = 0;
 }