开发者

Speed of NSArray#count

开发者_高级运维

If I do

[myArray count]

is it O(1) or O(n), where n is the number of elements in the array?


The source code of Core Foundation collections (upon which Foundation collections are built) is open source. If you inspect CFArray.c, you’ll see that __CFArrayGetCount() is O(1).


If it is not O(1) then you should find another array implementation :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜