lukaskubanek / OrderedDictionary

Ordered dictionary data structure implementation in Swift
MIT License
201 stars 63 forks source link

`filter` should return a new OrderedDictionary, not an array of Key-Value pairs #66

Closed joeljfischer closed 3 years ago

joeljfischer commented 4 years ago

When calling filter on an unordered Dictionary, you receive a new Dictionary, but oddly, when calling filter on an OrderedDictionary, you receive an array of tuples. I think it would be better to receive a new OrderedDictionary instead. It would also be good to have a new filtered method as well that filters in place.

lukaskubanek commented 4 years ago

Hi Joel, the filter(_:) method comes from the Sequence protocol OrderedDictionary conforms to. It’s, indeed, a good idea to have a specialized filter(_:) method which returns an OrderedDictionary. If you have an implementation to share, feel free to open a pull request.

lukaskubanek commented 3 years ago

Thanks again for reporting this feature request. In version 4.0, which is about to be released soon, your desired functionality for filter(_:) is already available. Check it out on the branch v4.0 (#69) or wait a few days till the version is officially released.