Is Swift dictionary of indexed for performance? Even for exotic types (UUID)?
问题 I want to construct some arrays that will remain in order to get fast searches. If I use something like this: let dictionary: [Int:Int] = [:] for i in 0 ..< 10000000 { dictionary[i] = 0 } Would the query: dictionary[n] == nil be performed in logarithmic time? If yes, is it the same for other types: Float, Double, String. And finally, I need it to work with the UUID type, will it work? 回答1: Swift's Dictionary is implemented with a hash table, therefore lookups will typically be done in O(1)