Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

objective-c complexity reference

For the c++ STL, there is a de-facto standard location (besides the de-jour standard, I mean) to find information about the complexity guarantees of standard container operations.

Is there an analogous, web-accessible document listing complexity guarantees for NSArray, NSDictionary, etc.?

For example, I cannot find a reference that gives complexity for [NSArray count]

like image 449
JRG Avatar asked Feb 21 '23 23:02

JRG


1 Answers

Correct. There isn't one. C++ / the STL (based on my limited understanding) have a significant performance focus. Objective-C / Foundation basically don't.

NSArray, NSDictionary and friends are interfaces. They tell you how to use them, not how they behave. This gives them the freedom to switch implementation under the hood for performance reasons. The point is, you don't need to care, and this won't be specified in the API so you can't even if you want to ;)

For a really good read on this subject, highlighting implementation switches, and with a rough comparison between Foundation classes and STL / C data structures, check out the Ridiculous Fish (by someone on the Apple AppKit team) blog post about "Our arrays, aren't"

like image 121
Kristian Glass Avatar answered Feb 28 '23 00:02

Kristian Glass