Exemplo n.º 1
0
        public override byte[] FindKey(TKey key)
        {
            int nextResult = this.records[0].Key.CompareTo(key);

            int idx = 0;

            while (idx < this.records.Length)
            {
                int thisResult = nextResult;

                if (idx + 1 < this.records.Length)
                {
                    nextResult = this.records[idx + 1].Key.CompareTo(key);
                }
                else
                {
                    nextResult = 1;
                }

                if (thisResult > 0)
                {
                    // This record's key is too big, so no chance further records
                    // will match.
                    return(null);
                }

                if (nextResult > 0)
                {
                    // Next record's key is too big, so worth looking at children
                    BTreeKeyedNode <TKey> child = ((BTree <TKey>) this.Tree).GetKeyedNode(this.records[idx].ChildId);
                    return(child.FindKey(key));
                }

                idx++;
            }

            return(null);
        }
Exemplo n.º 2
0
 public byte[] Find(TKey key)
 {
     return(_rootNode == null ? null : _rootNode.FindKey(key));
 }