/// <summary> /// Gets the lower and upper bounds of this tree. /// </summary> /// <param name="lowerBounds">The first key in the tree</param> /// <param name="upperBounds">The final key in the tree</param> /// <remarks> /// If the tree contains no data. <see cref="lowerBounds"/> is set to it's maximum value /// and <see cref="upperBounds"/> is set to it's minimum value. /// </remarks> public void GetKeyRange(TKey lowerBounds, TKey upperBounds) { LeafStorage.SeekToFirstNode(); bool firstFound = LeafStorage.TryGetFirstRecord(lowerBounds, m_tempValue); LeafStorage.SeekToLastNode(); bool lastFound = LeafStorage.TryGetLastRecord(upperBounds, m_tempValue); if (firstFound && lastFound) { return; } lowerBounds.SetMax(); upperBounds.SetMin(); }
/// <summary> /// Gets the node index of the last leaf node in the tree. /// </summary> /// <param name="level">the level of the node requesting the lookup</param> /// <returns></returns> public uint GetLastIndex(byte level) { if (RootNodeLevel == level) { return(RootNodeIndexAddress); } uint nodeIndexAddress = RootNodeIndexAddress; byte nodeLevel = RootNodeLevel; while (nodeLevel > level) { SortedTreeNodeBase <TKey, SnapUInt32> currentNode = GetNode(nodeLevel); currentNode.SetNodeIndex(nodeIndexAddress); if (!currentNode.TryGetLastRecord(m_tmpValue)) { throw new Exception("Node is empty"); } nodeIndexAddress = m_tmpValue.Value; nodeLevel--; } return(nodeIndexAddress); }