On 20 Aug 2009, at 13:43, Devraj Mukherjee wrote:
Hi all, I have NSMutableArray (fixed length) that I wish to fill with unique values at each index from a source NSArray (fixed length, greater than the length of the target mutable array).
This sounds worrying. There is no such thing as a fixes length mutable array unless you specifically create your own subclass to behave like this. I think you're confusing what -initWithCapacity: and friends really do.
Realise that I can do this by writing a loop and check to see if a value has bee pre-filled, the last indexes take a while to fill (for obvious reasons of randomisation). Is there are better way of doing this?
Does the ordering of the objects in the final array actually matter? If so, looping through each object and checking for -containsObject: is your best approach. If ordering is not important then you shouldn't be using an array anyway; instead use NSMutableSet which is designed for this sort of thing. Possibly if testing shows this to be a performance bottleneck you could use both NSMutableArray and NSMutableSet together, one to store the ordered objects, one to quickly check if an object is already present.
-- "The secret impresses no-one, the trick you use it for is everything" - Alfred Borden (The Prestiege) _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to [email protected]
_______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
