Exemplo n.º 1
0
        /// <summary>
        /// Remove the specified node
        /// <p/>
        /// Note that the node is invalidated after this call, in fact may be allocated to a new use
        /// </summary>
        /// <param name='node'>
        /// node to be removed
        /// </param>
        public virtual bool Remove(Node node)
        {
            bool removed = false;

            if (node == _front)
            {
                _front = node.Next; removed = true;
            }
            if (node == _back)
            {
                _back = node.Prior; removed = true;
            }

            if (node.Prior != null)
            {
                node.Prior.Next = node.Next; removed = true;
            }
            if (node.Next != null)
            {
                node.Next.Prior = node.Prior; removed = true;
            }

            node.Prior = null;
            node.Next  = null;

            if (removed)
            {
                _count--;
                NodePool <Node> .Free(node);
            }

            return(removed);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Clear list
        /// <p/>
        /// Note that all nodes are invalidated after this call, in fact may be allocated to a new use
        /// </summary>
        public virtual void Clear()
        {
            for (Node node = _front; node != null;)
            {
                var next = node.Next;
                NodePool <Node> .Free(node);

                node = next;
            }

            _front = null;
            _back  = null;
            _count = 0;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Append new node to list and return ref
 /// </summary>
 public virtual Node Append()
 {
     return(Append(NodePool <Node> .Alloc()));
 }
Exemplo n.º 4
0
 /// <summary>
 /// insert new node after given prior node, returning ref to new node
 /// </summary>
 /// <param name='prior'>
 /// Node to insert after
 /// </param>
 public virtual Node Insert(Node prior)
 {
     return(Insert(prior, NodePool <Node> .Alloc()));
 }