[swift-users] array.first vs. array[0]

Jordan Rose jordan_rose at apple.com
Thu Jan 21 22:00:30 CST 2016


> On Jan 21, 2016, at 16:36 , Jens Alfke via swift-users <swift-users at swift.org> wrote:
> 
> 
>> On Jan 21, 2016, at 2:51 PM, Dave Abrahams <dabrahams at apple.com <mailto:dabrahams at apple.com>> wrote:
>> 
>> It should say that Dictionary lookups are amortized O(1)
>> when the dictionary isn't backed by an NSDictionary
> 
> Isn’t NSDictionary O(1) too? It’s definitely a hash table.

The default implementation of NSDictionary is a hash table, but because you're allowed to subclass it (if discouraged <https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/index.html#//apple_ref/doc/uid/20000140-DontLinkElementID_1>) we can't 100% promise anything about a bridged dictionary's behavior.

Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160121/48115657/attachment.html>


More information about the swift-users mailing list