public BTree(int t, Func <IFile, IFile, int> comparer, StreamManager manager) { this.t = t; manager.OpenStream(); this.manager = manager; this.comparer = comparer; root = AllocateNode(); root.leaf = true; manager.UpdateRoot(root.offset, Array.IndexOf(MyFinder.comparer, comparer)); manager.DiskWrite(root); }
public void Add(IFile k) { Node r = this.root; if (r.n == 2 * t - 1) { //La raíz está llena. Separarla y crear una nueva Node s = AllocateNode(); this.root = s; s.leaf = false; s.c[0] = r.offset; SplitChild(r, s, 0); InsertNonFull(s, k); manager.UpdateRoot(s.offset, Array.IndexOf(MyFinder.comparer, comparer)); } else { InsertNonFull(r, k); } }