using System; using System.Diagnostics.Contracts; namespace DataStructures.BPlusTreeSpace { public partial class BPlusTree where TKey : IComparable { [Serializable] private class IntermediateNode : INode where TKey : IComparable { private readonly int numberOfChildren; private readonly TKey[] keys; private readonly INode[] children; public IntermediateNode(int numberOfChildren) { Contract.Requires(numberOfChildren > 2); keys = new TKey[numberOfChildren - 1]; children = new INode[numberOfChildren]; } //private int GetIndex(TKey key) //{ // // Simple linear search. Faster for small values of N or M // for (int i = 0; i < num; i++) // { // if (keys[i].CompareTo(key) > 0) // { // return i; // } // } // return num; //} //public INode public int GetLocation(TKey key) { const int errorNum = -1; // Simple linear search. Faster for small values of N or M for (int i = 0; i < keys.Length; i++) { if (keys[i].CompareTo(key) > 0) { return i; } } return errorNum; } } } }