Skip to content

4.0.0: MutableCollection & RandomAccessCollection

Compare
Choose a tag to compare
@lukaskubanek lukaskubanek released this 05 Apr 15:43
· 6 commits to master since this release
v4.0.0

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 to MutableCollection, 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 to RandomAccessCollection instead of BidirectionalCollection 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 the OrderedDictionary with different key-value pairs.
  • Introduced OrderedDictionary.filter(_:) that actually returns an OrderedDictionary instead of an array of key-value pairs. [#66]
  • Changed the type of OrderedDictionary.orderedKeys from a lazily evaluated collection type type-aliased with OrderedDictionaryKeys<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-level OrderedDictionaryValues<Key, Value> type alias, it now uses an inner type alias OrderedDictionary.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.