4.0.0: MutableCollection & RandomAccessCollection
This is a major overhaul of OrderedDictionary
's API that contains breaking changes. If you run into any issues upgrading from previous versions, please let me know.
OrderedDictionary
now conforms toMutableCollection
, which comes with the support for directly setting key-value pairs through a subscript as well as reordering of the whole collection or its slices.OrderedDictionary
now conforms toRandomAccessCollection
instead ofBidirectionalCollection
only, making the index-based traversal more efficient. [#64]- Re-introduced a dedicated slice type
OrderedDictionarySlice<Key, Value>
and added support for replacing a certain range of theOrderedDictionary
with different key-value pairs. - Introduced
OrderedDictionary.filter(_:)
that actually returns anOrderedDictionary
instead of an array of key-value pairs. [#66] - Changed the type of
OrderedDictionary.orderedKeys
from a lazily evaluated collection type type-aliased withOrderedDictionaryKeys<Key, Value>
to a[Key]
array. The property directly exposes the internal backing storage, which makes accessing keys more comfortable and prevents unnecessary type conversions. [#67] - The type of
OrderedDictionary.orderedValues
is still a lazily evaluated collection, but instead of the top-levelOrderedDictionaryValues<Key, Value>
type alias, it now uses an inner type aliasOrderedDictionary.LazyValues
. - Deprecated
OrderedDictionary.moveElement(forKey:to:)
as it was based on a very specific move logic which turned out not to be generally applicable. OrderedDictionary.update(_:at:)
now returns a non-optional key-value pair (Element
).- Improved performance of in-place sorting via
OrderedDictionary.sort(by:)
. - Added conformance to
Hashable
. - Dropped support for Swift 4.2, OrderedDictionary now requires Swift ≥5.0.
- Tweaked precondition messages and added invariant assertions.
- Revamped the whole test suite.
- Removed example playgrounds and moved examples directly to documentation comments.