// Deletes a list and returns the index of the next list.
        internal virtual int DeleteList(int list)
        {
            Clear(list);
            int prevList = m_lists.GetField(list, 2);
            int nextList = m_lists.GetField(list, 3);

            if (prevList != NullNode())
            {
                SetNextList_(prevList, nextList);
            }
            else
            {
                m_list_of_lists = nextList;
            }
            if (nextList != NullNode())
            {
                SetPrevList_(nextList, prevList);
            }
            FreeList_(list);
            return(nextList);
        }
Пример #2
0
 // Deletes a node from a list, given the previous node (previous node is
 // required, because the list is singly connected).
 internal virtual void DeleteElement(int list, int prevNode, int node)
 {
     if (prevNode != NullNode())
     {
         System.Diagnostics.Debug.Assert((m_listNodes.GetField(prevNode, 1) == node));
         m_listNodes.SetField(prevNode, 1, m_listNodes.GetField(node, 1));
         if (m_lists.GetField(list, 1) == node)
         {
             // deleting a tail
             m_lists.SetField(list, 1, prevNode);
         }
     }
     else
     {
         System.Diagnostics.Debug.Assert((m_lists.GetField(list, 0) == node));
         m_lists.SetField(list, 0, m_listNodes.GetField(node, 1));
         if (m_lists.GetField(list, 1) == node)
         {
             // removing last element
             System.Diagnostics.Debug.Assert((m_listNodes.GetField(node, 1) == NullNode()));
             m_lists.SetField(list, 1, NullNode());
         }
     }
     FreeNode_(node);
 }
 // returns the list associated with the node_index. Do not use if list is
 // created with bStoreListIndexWithNode == false.
 internal virtual int GetList(int node_index)
 {
     System.Diagnostics.Debug.Assert((m_b_store_list_index_with_node));
     return(m_list_nodes.GetField(node_index, 3));
 }
Пример #4
0
        // Deletes a list.
        internal virtual void DeleteList(int list)
        {
            int ptr = GetFirst(list);

            while (ptr != NullNode())
            {
                int p = ptr;
                ptr = GetNext(ptr);
                FreeNode_(p);
            }
            if (m_b_allow_navigation_between_lists)
            {
                int prevList = m_lists.GetField(list, 2);
                int nextList = m_lists.GetField(list, 3);
                if (prevList != NullNode())
                {
                    m_lists.SetField(prevList, 3, nextList);
                }
                else
                {
                    m_list_of_lists = nextList;
                }
                if (nextList != NullNode())
                {
                    m_lists.SetField(nextList, 2, prevList);
                }
            }
            FreeList_(list);
        }
Пример #5
0
 private int GetPriority_(int treap_node_index)
 {
     return(m_treapData.GetField(treap_node_index, 4));
 }