Exemplo n.º 1
0
        private T NextAsc()
        {
            // Try to go down till a leaf
            while (!CurrentNode.IsLeaf())
            {
                CurrentNode      = CurrentNode.GetChildAt(_currentKeyIndex, true);
                _currentKeyIndex = 0;
            }

            // If leaf has more keys
            if (_currentKeyIndex < CurrentNode.GetNbKeys())
            {
                NbReturnedElements++;
                var nodeValue = GetValueAt(CurrentNode, _currentKeyIndex);
                _currentKeyIndex++;
                return((T)nodeValue);
            }

            // else go up till a node with keys
            while (_currentKeyIndex >= CurrentNode.GetNbKeys())
            {
                var child = CurrentNode;
                CurrentNode      = CurrentNode.GetParent();
                _currentKeyIndex = IndexOfChild(CurrentNode, child);
            }

            NbReturnedElements++;

            var value = GetValueAt(CurrentNode, _currentKeyIndex);

            _currentKeyIndex++;
            return((T)value);
        }