mirror of
https://github.com/apple/swift-collections
synced 2026-11-28 05:04:21 +00:00
Reworks the relocation API and extends it to `OrderedDictionary`: * Renames the index-range move to `moveSubrange(_:to:)` (with a `RangeExpression` overload) and the by-value move to `move(contentsOf:to:)`, matching the conventions of `removeSubrange`/`insert(_:at:)`. Adds `move(fromIndices:to:)`, which takes the source indices directly. * Factors the element rearrangement into generic `UnsafeMutableBufferPointer` operations (rotation / rotation+permutation / scatter) so `OrderedDictionary` relocates its keys and values in lockstep through the same code, adding only the parallel value move; the hash-table maintenance stays entirely in `OrderedSet`. * The hot path runs in O(*d* + *k*) and falls back to O(`count`) for large moves; bucket maintenance chooses targeted updates or a full rebuild by the same threshold. * `move(contentsOf:to:)` ignores elements/keys that aren't present; duplicate members are detected and trap. Adds tests (exhaustive hash-table integrity, value alignment under lifetime tracking) and move benchmarks for both types.