- Reactive Programming with Swift 4
- Navdeep Singh
- 127字
- 2021-06-24 18:57:58
Reserving capacity
Dictionary and sequence now have the capacity to explicitly, unambiguously reserve capacity.
Suppose you have a sequence of friends with an initial capacity of 4:
friends.capacity // 4
You can now reserve the capacity by doing this:
friends.reserveCapacity(20)
This reserves a minimum of 20 segments of capacity:
friends.capacity // 20
Reallocating memory to objects can be an expensive task, and if you have an idea about how much space it will require to store an object, then using reserveCapacity(_:) can be an easy and simple way to increase performance.
Swift 4 brings in a number of modifications to the Dictionary, 12 to be exact as per the official Apple developers guide, and a number of additions that we will discuss in subsequent sections:

推薦閱讀
- 數據庫系統原理及MySQL應用教程(第2版)
- JavaScript百煉成仙
- ReSharper Essentials
- Learn Type:Driven Development
- Internet of Things with the Arduino Yún
- Java設計模式及實踐
- Mastering Android Development with Kotlin
- Getting Started with Hazelcast(Second Edition)
- 軟件測試實用教程
- RealSenseTM互動開發實戰
- Mastering SciPy
- Python機器學習
- Learning PrimeFaces Extensions Development
- C++程序設計習題與實驗指導
- Oracle 11g寶典