Re: Is checking -count worth it?
Re: Is checking -count worth it?
- Subject: Re: Is checking -count worth it?
- From: Ken Thomases <email@hidden>
- Date: Thu, 24 Jul 2008 03:45:39 -0500
On Jul 24, 2008, at 2:02 AM, Matthew Schinckel wrote:
Am I better off in general (ie, adding objects, removing objects,
etc) using an NS(Mutable)Set instead of an NSArray, if I don't need
sorting and duplicate items?
Since the semantics of an NSSet are "looser" than those for an NSArray
(as you point out), then you can freely use an NSSet wherever you
don't need the tighter semantic requirements of an array. The looser
requirements allow for greater flexibility in implementation.
Think of it this way: if NSArray were really faster/cheaper than an
NSSet, then you can assume that NSSet would use an NSArray for its
implementation and they'd be equivalent.
However, beyond any consideration of performance, just use the data
structure which accurately reflects the semantics of your design.
From a design perspective, is your to-many relationship a set or an
array?
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden