When removing elements from a B-tree, the root node could become empty while still having children. The previous code incorrectly called drop() which deallocated all children, causing massive data loss during removal operations.
This fix implements proper root reduction by moving the single remaining child out of the empty root, then safely dropping the now-empty parent node and promoting the extracted child to become the new root.
This fixes `test_modifySubscriptRemoval` in `SortedDictionaryTests`, so we re-enable SortedDictionary tests which now all pass.
`findAnyIndex(forKey:)` miscomputed the global offset when a key was found in an internal B-tree node, due to missing child subtree counts in the calculation.
Key Changes:
- Add tests and benchmarks for SortedSet
- Fix bug during _Node.UnsafeHandle.popFirstElement() rebalancing
- Enable _Node.UnsafeHandle.subscript(elementAt:) to work on value-less nodes.
Minor Changes:
- Optimize Codable to use _BTree.Builder and forEach
- Codable now checks for order, not strictly uniqueness
- Add smaller node size for debug builds to easily catch errors
Key Changes:
- Implement Equatable, Hashable for SubSequences
- Implement SortedDictionary initializers
- init(keysWithValues:) and init(sortedKeysAndValues:) with named and unnamed variants.
- Expand benchmark suite for SortedDictionary
- Commit _BTree.Builder
Minor Changes:
- Update documentation
- Expand test suits
- Fix bug where SubSequences did not define subscript(bounds: Range<Index>)
- _Node
- Implement `depth` property for `_Node`
- Packs both `depth`, `count`, and `capacity` within a single UInt64.
- Implement `init(leftChild:seperator:rightChild:capacity:)` for `_Node`
- Implement `concatenateWith(node:seperatedBy:)` to `_Node.UnsafeHandle`
- Remove bad invariant check on `_Node.UnsafeHandle` deletion subroutines
- _BTree
- Add invariant checks as `_BTree.checkInvariants()`
- Separate `_BTree.*capacity` into `*size` and `*capacity`
- Make _FixedSizeArray top-level
- Remove deque behavior.
Documentation:
- Update complexity documentation style from 'n' to `self.count`
Testing:
- Expand tests for SortedDictionary
- Add tests for SortedDictionary.Keys
- Add tests for _Node.join(...) routines
- Add tests for _BTree.Builder
- Restore checkBidirectionalCollection tests for _BTree
Major Changes:
- Implement Sequence for SortedSet
Minor Changes:
- Fix bug within _Node.UnsafeHandle.pointerToChild(atSlot:)
- Cleanup cursor implementation and fix bugs.
- Fix various bugs in _BTree.FixedSizeArray
Key Changes:
- Implement deficiency correction methods
- Remove inlining from _Node.ensureUnique to better inline closures
- Add new computed properties to _Node.UnsafeHandle
Minor changes
- Added missing mutability checks to certain _Node.UnsafeHandle methods
- Remove unneeded _Node.UnsafeHandle.findValue(key:) method
- Allow _Node.UnsafeHandle.removeElement(at:) to be called on non-leaves
- Expand doc comments and fix typos