Ejemplo n.º 1
0
        // Adds element to a given list. The element is added to the end. Returns
        // the new
        internal virtual int AddElement(int list, int element)
        {
            int head = m_lists.GetField(list, 0);
            int tail = m_lists.GetField(list, 1);
            int node = NewNode_();

            if (tail != NullNode())
            {
                System.Diagnostics.Debug.Assert((head != NullNode()));
                m_listNodes.SetField(tail, 1, node);
                m_lists.SetField(list, 1, node);
            }
            else
            {
                // empty list
                System.Diagnostics.Debug.Assert((head == NullNode()));
                m_lists.SetField(list, 0, node);
                m_lists.SetField(list, 1, node);
            }
            m_listNodes.SetField(node, 0, element);
            return(node);
        }
 internal virtual void SetListSize_(int list, int newsize)
 {
     m_lists.SetField(list, 4, newsize);
 }
 internal virtual void SetPrev_(int node, int prev)
 {
     m_list_nodes.SetField(node, 1, prev);
 }
Ejemplo n.º 4
0
        // Creates new list and returns it's handle.
        internal virtual int CreateList()
        {
            int node = NewList_();

            if (m_b_allow_navigation_between_lists)
            {
                m_lists.SetField(node, 3, m_list_of_lists);
                if (m_list_of_lists != NullNode())
                {
                    m_lists.SetField(m_list_of_lists, 2, node);
                }
                m_list_of_lists = node;
            }
            return(node);
        }
Ejemplo n.º 5
0
 private void SetParent_(int treap_node_index, int new_parent)
 {
     m_treapData.SetField(treap_node_index, 2, new_parent);
 }