Ejemplo n.º 1
0
 /// <summary>
 /// Clears this instance. It doesn't reset the individual nodes, it just cuts off references to head and tail so the list contents goes
 /// out of scope.
 /// </summary>
 public void Clear()
 {
     if (_head != null)
     {
         // just cut off head and tail (it's a linked list, people, not a living being ;)). The rest will go out of scope.
         _head.RemoveFromList();
         _head = null;
         _tail.RemoveFromList();
         _tail  = null;
         _count = 0;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes the specified bucket from the list.
        /// </summary>
        /// <param name="toRemove">To remove.</param>
        /// <remarks>Routine assumes the passed in bucket is in the linked bucket list managed by this instance</remarks>
        /// <returns>true if remove took place, otherwise false</returns>
        public bool Remove(ListBucket <T> toRemove)
        {
            if (toRemove == null)
            {
                return(false);
            }

            if (_head == toRemove)
            {
                _head = toRemove.Next;
            }
            if (_tail == toRemove)
            {
                _tail = toRemove.Previous;
            }

            toRemove.RemoveFromList();
            _count--;
            return(true);
        }