pointfreeco / swift-identified-collections

A library of data structures for working with collections of identifiable elements in an ergonomic, performant way.
MIT License
531 stars 45 forks source link

Add read-only `elements` getter to `IdentifiedArray` #12

Closed p4checo closed 3 years ago

p4checo commented 3 years ago

Until now there was no public API to efficiently return the elements from the underlying storage of IdentifiedArray as an [Element], requiring an O(n) map { $0 } via Collection to achieve this.

By taking advantage of the existing O(1) OrderedDictionary.values and OrderedDictionary.Values.elements getters, we can efficiently provide an O(1) read-only view of the elements in a more ergonomic way.

Changes