Files
knowledge-kit/Chapter1 - iOS/1.129.md
2024-04-27 13:01:58 +08:00

373 B

Swift Dictionary 扩容机制

Dictionary

let dic = ["d": 4, "a": 1, "b": 2, "c": 3]
print(dic)
// ["c": 3, "d": 4, "a": 1, "b": 2]

Dictionary 顺序会乱序

KeyValuePairs

KeyValuePairs 顺序不会乱序

let kvs: KeyValuePairs = ["d": 4, "a": 1, "b": 2, "c": 3]
print(kvs)
// ["d": 4, "a": 1, "b": 2, "c": 3]

开放寻址法