Beispiel #1
0
    private BinaryElement <TKey, TValue> InsertElement(int _index, BinaryElement <TKey, TValue> _b_element)
    {
        BinaryElement <TKey, TValue> result = null;

        InsertInArray(_index, _b_element);

        if (m_elements_count >= m_keys.Length)
        {
            int mid = m_elements_count / 2;
            Pair <TKey, TValue> median = m_keys[mid];
            m_keys[mid] = null;

            BTreeElement <TKey, TValue> right = New();
            right.Init(m_max_elements);

            for (int i = mid + 1, ir = 0; i < m_elements_count; ++i, ++ir)
            {
                right.m_keys[ir] = m_keys[i];
                m_keys[i]        = null;
            }

            for (int i = mid + 1, ir = 0, count = m_elements_count + 1; i < count; ++i, ++ir)
            {
                right.m_neighbors[ir] = m_neighbors[i];
                m_neighbors[i]        = null;
            }

            right.m_elements_count = m_elements_count - mid - 1;
            m_elements_count       = mid;

            result = new BinaryElement <TKey, TValue>(this, right, median);
        }

        return(result);
    }
Beispiel #2
0
    public void Insert(TKey _key, TValue _value)
    {
        BinaryElement <TKey, TValue> insert = m_root.Insert(_key, _value);

        if (insert != null)
        {
            m_root = m_root.New();
            m_root.Init(m_max_elements, insert);
        }
    }
Beispiel #3
0
 public BinaryElement(BTreeElement <TKey, TValue> _left, BTreeElement <TKey, TValue> _right, Pair <TKey, TValue> _value)
 {
     Left  = _left;
     Right = _right;
     Value = _value;
 }
Beispiel #4
0
 protected void SetNeighbor(int _index, BTreeElement <TKey, TValue> _element)
 {
     m_neighbors[_index] = _element;
 }
Beispiel #5
0
 private void Init()
 {
     m_root = new TTreeElement();
     m_root.Init(m_max_elements);
 }