OrderedDictionary only a Partial RangeReplaceableCollection? I'm looking to swap out my current
Array<(IDType, ValueType)> for an
OrderedDictionary<IDType, ValueType>, but rely on
replaceSubrange, which is not implemented for
OrderedDictionary. Wouldn't this method work with a dictionary literal as the
newValues replacement argument?
RandomAccessCollection API as well as a subset of the
RangeReplaceableCollection API can be found under the
elements computed property, to avoid confusion between element access by key and by index.
However, the uniqueness of keys isn't guaranteed in dictionary literals, and in case of
replaceSubrange, it would not be enough for the literal to have unique keys; it should neither contain any of the keys existing outside the subrange being replaced.
Bottom line remains that there is no
replaceSubrange equivalent. I think there should be one.
OrderedDictionary needs to ensure that its keys are unique, and this requirement is incompatible with arbitrary insertions and replacements.