コード例 #1
0
 /// <summary>
 /// Make an iterator that will loop thru the collection in order.
 /// </summary>
 /// <param name="dictionary">
 /// <see cref="SortedBPlusTreeDictionary&lt;TKey,TValue&gt;"/>
 /// containing these key/value pairs.
 /// </param>
 public Enumerator(SortedBPlusTreeDictionary <TKey, TValue> dictionary)
 {
     currentLeaf = null;
     leafIndex   = 0;
     _version    = 0;
     target      = dictionary;
     Reset();
 }
コード例 #2
0
ファイル: BPlusTree.Path.cs プロジェクト: theassyrian/Bee
            /// <summary>
            /// Get the node to the immediate left of the node at TreePath.
            /// </summary>
            internal SortedBPlusTreeDictionary <TKey, TValue> .Node GetLeftNode()
            {
                Debug.Assert(indexStack.Count == nodeStack.Count);

                for (int depth = indexStack.Count - 2; depth >= 0; --depth)
                {
                    if (indexStack[depth] > 0)
                    {
                        SortedBPlusTreeDictionary <TKey, TValue> .Node result = ((SortedBPlusTreeDictionary <TKey, TValue> .InternalNode)nodeStack[depth]).GetChild(indexStack[depth] - 1);
                        for (; depth < indexStack.Count - 2; ++depth)
                        {
                            result = ((SortedBPlusTreeDictionary <TKey, TValue> .InternalNode)result).GetChild(result.KeyCount);
                        }
                        return(result);
                    }
                }
                return(null);
            }
コード例 #3
0
ファイル: BPlusTree.Path.cs プロジェクト: theassyrian/Bee
            /// <summary>Perform search and store each level of path on the stack.</summary>
            /// <param name="tree">Tree to search.</param>
            /// <param name="key">Value to find.</param>
            internal TreePath(SortedBPlusTreeDictionary <TKey, TValue> tree, TKey key)
            {
                indexStack = new List <int>();
                nodeStack  = new List <SortedBPlusTreeDictionary <TKey, TValue> .Node>();

                SortedBPlusTreeDictionary <TKey, TValue> .Node node = tree._root;

                for (; ;)
                {
                    Debug.Assert(node != null);

                    nodeStack.Add(node);
                    int i = node.Search(key, tree._comparer);

                    if (node is SortedBPlusTreeDictionary <TKey, TValue> .LeafNode)
                    {
                        IsFound = i >= 0;
                        if (!IsFound)
                        {
                            i = ~i;
                        }
                        indexStack.Add(i);
                        return;
                    }

                    if (i < 0)
                    {
                        i = ~i;
                    }
                    else
                    {
                        ++i;
                    }

                    indexStack.Add(i);
                    node = ((SortedBPlusTreeDictionary <TKey, TValue> .InternalNode)node).GetChild(i);
                }
            }
コード例 #4
0
ファイル: BPlusTree.Path.cs プロジェクト: theassyrian/Bee
            /// <summary>Adjust tree path to node to the right.</summary>
            /// <returns>Node to immediate right of current path; <b>null</b> if current path
            /// at rightmost node.</returns>
            internal SortedBPlusTreeDictionary <TKey, TValue> .Node TraverseRight()
            {
                SortedBPlusTreeDictionary <TKey, TValue> .Node node = null;
                int height = indexStack.Count;

                for (; ;)
                {
                    if (indexStack.Count < 2)
                    {
                        Clear();
                        node = null;
                        break;
                    }

                    Pop();
                    node = TopNode;
                    int newIndex = TopNodeIndex + 1;

                    if (newIndex < ((SortedBPlusTreeDictionary <TKey, TValue> .InternalNode)node).ChildCount)
                    {
                        indexStack[indexStack.Count - 1] = newIndex;
                        node = ((SortedBPlusTreeDictionary <TKey, TValue> .InternalNode)node).GetChild(newIndex);
                        for (; ;)
                        {
                            Push(node, 0);
                            if (indexStack.Count >= height)
                            {
                                break;
                            }
                            node = ((SortedBPlusTreeDictionary <TKey, TValue> .InternalNode)node).FirstChild;
                        }
                        break;
                    }
                }

                return(node);
            }
コード例 #5
0
 /// <summary>
 /// Make a new <b>"BPlusTreeDictionary&lt;TKey,TValue&gt;.KeyCollection</b> that
 /// holds the keys of a <see cref="SortedBPlusTreeDictionary&lt;TKey,TValue&gt;"/>.
 /// </summary>
 /// <param name="dictionary">
 /// <see cref="SortedBPlusTreeDictionary&lt;TKey,TValue&gt;"/> containing these keys.
 /// </param>
 public BPlusTreeKeys(SortedBPlusTreeDictionary <TKey, TValue> dictionary)
 {
     this.tree = dictionary;
 }
コード例 #6
0
 // Long form used for 5% performance increase.
 public BPlusTreeValuesEnumerator(SortedBPlusTreeDictionary <TKey, TValue> tree)
 {
     target = tree;
     Reset();
 }
コード例 #7
0
 /// <summary>
 /// Make a new <b>"BPlusTreeDictionary&lt;TKey,TValue&gt;.ValueCollection</b> that
 /// holds the values of a <see cref="SortedBPlusTreeDictionary&lt;TKey,TValue&gt;"/>.
 /// </summary>
 /// <param name="dictionary">
 /// <see cref="SortedBPlusTreeDictionary&lt;TKey,TValue&gt;"/> containing these keys.
 /// </param>
 public BPlusTreeValues(SortedBPlusTreeDictionary <TKey, TValue> dictionary)
 {
     this._target = dictionary;
 }
コード例 #8
0
 /// <summary>
 /// Make an enumerator that will loop thru the collection in order.
 /// </summary>
 /// <param name="dictionary">
 /// <see cref="SortedBPlusTreeDictionary&lt;TKey,TValue&gt;"/>
 /// containing these key/value pairs.
 /// </param>
 public BPlusTreeObjectEnumerator(SortedBPlusTreeDictionary <TKey, TValue> dictionary)
 {
     target = dictionary;
     Reset();
 }
コード例 #9
0
ファイル: BPlusTree.Path.cs プロジェクト: theassyrian/Bee
 internal void Push(SortedBPlusTreeDictionary <TKey, TValue> .Node newNode, int newNodeIndex)
 {
     nodeStack.Add(newNode);
     indexStack.Add(newNodeIndex);
 }