[swift-evolution] Dictionary Enhancements

Haravikk swift-evolution at haravikk.me
Fri Feb 17 04:54:35 CST 2017

> On 17 Feb 2017, at 00:26, Ben Cohen via swift-evolution <swift-evolution at swift.org> wrote:
> Hi swift-evolution,
> Add capacity property and reserveCapacity() method.

Just wanted to quickly weigh in on this one, but I wonder if this might make most sense coming as a slight restructuring of the collection protocols. It could for example make sense as an ExtendableCollection protocol, which could also take a general purpose add/insert method (in the case of Dictionary this would take a Key/Value pair), which I believe is something that's also lacking from Dictionary?

Basically it's a protocol representing a Collection whose contents can grow, but which places no guarantees over ordering. So unlike append() you're not guaranteed to have the new element under .last. It makes sense to group with capacity since you don't need capacity in something that can't expand in some way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170217/2546690f/attachment.html>

More information about the swift-evolution mailing list