mirror of
https://github.com/apple/swift-collections
synced 2026-11-25 04:37:48 +00:00
Per review feedback, relax the precondition so that the new key may compare equal to the key currently stored at index. This enables replacing an existing key with an equal-but-not-identical instance — for example, swapping a decomposed Unicode string with its precomposed equivalent — without an inefficient remove/insert workaround. When the new key matches the one being replaced, the pair is updated in place via OrderedSet.update(_:at:) and the hash table is left untouched, preserving the expected amortized O(1) complexity. Add a test_replaceElement_sameKey test on both OrderedDictionary and its Elements view that exercises the new path with LifetimeTracked keys carrying equal payloads but distinct instances.