/// <summary> /// Removes the specified leaf node from the sparse index /// </summary> /// <param name="key">The leaf node to remove</param> /// <param name="level"></param> public void Remove(TKey key, byte level) { if (level <= RootNodeLevel) { SortedTreeNodeBase <TKey, SnapUInt32> node = GetNode(level); if (!node.TryRemove(key)) { throw new KeyNotFoundException(); } if (level == RootNodeLevel) { if (node.RightSiblingNodeIndex == uint.MaxValue && node.LeftSiblingNodeIndex == uint.MaxValue && node.RecordCount == 1) { RootNodeLevel--; node.TryGetFirstRecord(m_tmpKey, m_tmpValue); RootNodeIndexAddress = m_tmpValue.Value; node.Clear(); } } } else { throw new Exception("Cannot update value of root"); } }