Re: [question] Checking for duplicate entries in NSMutableArray
Re: [question] Checking for duplicate entries in NSMutableArray
- Subject: Re: [question] Checking for duplicate entries in NSMutableArray
- From: Martin Wierschin <email@hidden>
- Date: Mon, 8 Oct 2007 16:16:41 -0700
Guy's suggestions are all good. The one thing I personally would
change is the hash implementation:
- (unsigned) hash
{
return [[NSString stringWithFormat: @"%@%@", [self firstName],
[self lastName]] hash];
}
Simple is good, but hashing should be fast, and creating a temporary
string is unnecessary. I'd just combine the hashes using a bitwise or
arithmetic operator, eg:
- (unsigned) hash
{
return [[self firstName] hash] ^ [[self lastName] hash];
}
~Martin
_______________________________________________
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