lukaskubanek / OrderedDictionary

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

adds capacity getter and reserveCapacity method #54

Closed GalCohen closed 4 years ago

GalCohen commented 4 years ago

Seems like a useful addition that exists on standard library types. Hope the implementation is okay!

GalCohen commented 4 years ago

Hi @lukaskubanek - any thoughts on this addition?

lukaskubanek commented 4 years ago

Hi @GalCohen, thanks for your pull request and your patience. In the recent weeks, I was busy launching the app this library was primarily developed for. I’ll come back to this pull request in the next days.

lukaskubanek commented 4 years ago

Hi @GalCohen, thanks for this useful addition. I went a step further and added OrderedDictionary.init(minimumCapacity:) as well as some basic tests covering this functionality.

Further, I’ve changed the logic of OrderedDictionary.capacity to use the minimum reserved capacity of the underlying types (Array and Dictionary) to prevent false reports. The Dictionary typically allocates larger portions of memory and thus depending on this value might still lead to reallocation of the Array type.

You can find all changes in the merge commit f303e02f635bf9a28eb605077aa73b346849003a.

GalCohen commented 4 years ago

Thanks for merging in my PR @lukaskubanek ! Your revisions make sense. Best of luck of with new app!