public bool Remove(L2ListElem elem)
#endif
        {
            lock (this)
            {
                if (elem.prev != null)
                {
                    elem.prev.next = elem.next;
                    elem.prev.Modify();
                    elem.prev = null;
                    elem.Modify();
                }
                else
                {
                    head = head.next;
                }
                if (elem.next != null)
                {
                    elem.next.prev = elem.prev;
                    elem.next.Modify();
                    elem.next = null;
                    elem.Modify();
                }
                else
                {
                    tail = tail.prev;
                }
                nElems        -= 1;
                updateCounter += 1;
                Modify();
                return(true);
            }
        }
示例#2
0
 /// <summary>
 /// Link specified element in the list before this element
 /// </summary>
 public void LinkBefore(L2ListElem elem)
 {
     Modify();
     prev.Modify();
     elem.Modify();
     elem.next = this;
     elem.prev = prev;
     prev.next = elem;
     prev      = elem;
 }
示例#3
0
 /// <summary>
 /// Link specified element in the list after this element
 /// </summary>
 public void LinkAfter(L2ListElem elem)
 {
     Modify();
     next.Modify();
     elem.Modify();
     elem.next = next;
     elem.prev = this;
     next.prev = elem;
     next      = elem;
 }
        public bool Contains(L2ListElem obj)
        {
            foreach (L2ListElem o in this)
#endif
            {
                if (o == obj)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#5
0
 public bool MoveNext()
 {
     if (counter != list.updateCounter)
     {
         throw new InvalidOperationException();
     }
     if (curr.next == list)
     {
         return(false);
     }
     curr = curr.next;
     return(true);
 }
示例#6
0
 /// <summary>
 /// Remove element from the list
 /// </summary>
 public void Remove(L2ListElem elem)
 {
     lock (this)
     {
         Modify();
         elem.prev.Modify();
         elem.next.Modify();
         elem.next.prev = elem.prev;
         elem.prev.next = elem.next;
         nElems        -= 1;
         updateCounter += 1;
     }
 }
示例#7
0
 /// <summary>
 /// Insert element at the end of the list
 /// </summary>
 public void Append(L2ListElem elem)
 {
     lock (this)
     {
         Modify();
         prev.Modify();
         elem.Modify();
         elem.next      = this;
         elem.prev      = prev;
         prev.next      = elem;
         prev           = elem;
         nElems        += 1;
         updateCounter += 1;
     }
 }
示例#8
0
 /// <summary>
 /// Insert element at the beginning of the list
 /// </summary>
 public void Prepend(L2ListElem elem)
 {
     lock (this)
     {
         Modify();
         next.Modify();
         elem.Modify();
         elem.next      = next;
         elem.prev      = this;
         next.prev      = elem;
         next           = elem;
         nElems        += 1;
         updateCounter += 1;
     }
 }
 public bool MoveNext()
 {
     if (counter != list.updateCounter)
     {
         throw new InvalidOperationException();
     }
     if (head)
     {
         curr = list.head;
         head = false;
     }
     else if (curr != null)
     {
         curr = curr.next;
     }
     return(curr != null);
 }
        public void Append(L2ListElem elem)
#endif
        {
            lock (this)
            {
                elem.next = null;
                elem.prev = tail;
                elem.Modify();
                if (tail != null)
                {
                    tail.next = elem;
                    tail.Modify();
                }
                else
                {
                    tail = elem;
                }
                tail           = elem;
                nElems        += 1;
                updateCounter += 1;
                Modify();
            }
        }
        public void Prepend(L2ListElem elem)
#endif
        {
            lock (this)
            {
                elem.next = head;
                elem.prev = null;
                elem.Modify();
                if (head != null)
                {
                    head.prev = elem;
                    head.Modify();
                }
                else
                {
                    tail = elem;
                }
                head           = elem;
                nElems        += 1;
                updateCounter += 1;
                Modify();
            }
        }
 public void Reset()
 {
     curr    = null;
     counter = list.updateCounter;
     head    = true;
 }
        public void Add(L2ListElem elem)
#endif
        {
            Append(elem);
        }
示例#14
0
 /// <summary>
 /// Make list empty.
 /// This method should be applied to list header.
 /// </summary>
 public void Prune()
 {
     next = prev = null;
     Modify();
 }
示例#15
0
 public void Reset()
 {
     curr    = list;
     counter = list.updateCounter;
 }
示例#16
0
 /// <summary>
 /// Make list empty.
 /// This method should be applied to list header.
 /// </summary>
 public void Prune()
 {
     Modify();
     next = prev = null;
 }