Question on capacity parameter for CF mutable collection
Question on capacity parameter for CF mutable collection
- Subject: Question on capacity parameter for CF mutable collection
- From: j o a r <email@hidden>
- Date: Mon, 11 Apr 2005 15:48:50 +0200
Hello,
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.
=========================================================
Compare this with the method used to create a NSMutableArray:
=========================================================
- (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?
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden