The last operation the single-node index needs is removal. Today you delete a key from the root leaf, closing the gap so the entries stay sorted and packed - rebalancing across nodes comes later.
Remove a key and its value from the root leaf, keeping the remaining entries sorted, and report whether it was there.
Delete finds the key with the same binary search, then removes its entry and
closes the gap by shifting the later entries left, keeping the leaf sorted and
packed. A miss changes nothing and returns false, so callers can tell a real
deletion from a no-op.
While the whole tree is one leaf, deletion is this simple - there is no parent to notify and no sibling to rebalance against. The root leaf is even allowed to shrink to empty, because the root is special: it never underflows. That freedom ends once the tree has more than one node, where a leaf that drops too low has to borrow from or merge with a neighbor - the subject of the delete-and-rebalance chapter. First, the next chapter makes the tree grow past a single leaf at all.
func (t *Tree) Delete(key uint64) bool {leaf := parseLeaf(t.pager.ReadPage(t.root))i, found := searchLeaf(leaf.Keys, key)if !found { return false }// remove entry i from Keys and Vals (shift the rest left)t.pager.WritePage(t.root, serializeLeaf(leaf))return true}