• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [question] Checking for duplicate entries in NSMutableArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >[question] Checking for duplicate entries in NSMutableArray (From: email@hidden)
 >Re: [question] Checking for duplicate entries in NSMutableArray (From: Guy English <email@hidden>)

  • Prev by Date: Custom compare: for NSDate sort descriptor
  • Next by Date: Re: Core Data: rare exception
  • Previous by thread: Re: [question] Checking for duplicate entries in NSMutableArray
  • Next by thread: Re: [question] Checking for duplicate entries in NSMutableArray
  • Index(es):
    • Date
    • Thread