mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
When the key was found at slot k of an internal node but an earlier occurrence was sought in the child subtree and not found, the fallback path returned the internal-node element's position. The absolute offset formula for element[k] in a non-leaf node is: ancestors + sum(subtreeCount[0..k]) + k The `+ k` (slot) term was omitted, so the returned index carried the wrong offset for any key that lives at slot > 0 of an internal node. Add test_startIndexForKey (BTree Tests) to verify the offset for every key in trees of several sizes, and test_rangeSubscript (SortedSet Tests) to exercise the SortedSet[range] subscript which depends on this method. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Unit tests
Beware! The contents of this directory are not source stable. They are provided as is, with no compatibility promises across package releases. Future versions of this package can arbitrarily change these files or remove them, without any advance notice. (This can include patch releases.)