Question on capacity parameter for CF mutable collection
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hello, Compare this with the method used to create a NSMutableArray: j o a r _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com I'm sorry if this question is off-topic for this list. Darwin contains parts of CF, and there is no specific CF list, so perhaps it's on topic... I have a hopefully simple API question. Consider the function used to create a CFMutableArray (as an example of a mutable collection, the other mutable collections in CF are implemented in the same way): ========================================================= CFMutableArrayRef CFArrayCreateMutable ( CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks ); ========================================================= capacity The maximum number of values that can be contained by the CFArray. The array starts empty and can grow to this number of values (and it can have less). If this parameter is 0, the array’s maximum capacity is unlimited (or rather, only limited by address space and available memory constraints). If this parameter is negative, the behavior is undefined. ========================================================= ========================================================= - (id)initWithCapacity:(unsigned)numItems Initializes a newly allocated array, giving it enough memory to hold numItems objects. Mutable arrays expand as needed, so numItems simply establishes the object’s initial capacity. Returns an initialized object, which might be different than the original receiver. ========================================================= Note the difference between how the capacity parameters are used. I can see why you for performance reasons would like to be able to "hint" at the number of objects that's going to be added to a mutable collection, and I don't quite see why the mutable CF collections doesn't allow this? Why would you like to set a max limit for a mutable collection? Why is it not possible to hint at the required capacity? smime.p7s
participants (1)
-
j o a r