コード例 #1
0
        /// <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);
        }