Re: Hash Values in Custom Classes
Re: Hash Values in Custom Classes
- Subject: Re: Hash Values in Custom Classes
- From: Peter Lübke <email@hidden>
- Date: Mon, 28 Mar 2011 15:42:23 +0200
To be more detailed: my custom class and its subclasses are
wrapper classes containing file informations. They are based on
FSRef rather than using paths - I do a lot of lengthy iterations
so paths are much too fragile. I also heavily use NSSet to store
instances, and I wanted -isEqual: to be as fast as possible. So I
thought I could just return a unique hash value for each custom
class and return (FSCompareFSRefs (&ownRef, &otherRef) == noErr)
for -isEqual:, thus avoiding the need to *first* compare the
objects' classes.
Am 28.03.2011 um 01:23 schrieb Mike Abdullah:
....
http://www.mikeash.com/pyblog/friday-qa-2010-05-28-leopard-
collection-classes.html
Good link, particularly NSPointerArray might come in handy in future
projects.
I trust you have profiled your code etc. before deciding this is
worth your while…
For my current project, NSSet works fine. I'll test for class
identity before calling FSCompareFSRefs() in the -isEqual: methods of
my custom classes, so I'm not dependant on *absolute* uniqueness of
the values they return for -hash.
Cheers,
Peter_______________________________________________
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