• 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
NSUInteger hash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSUInteger hash


  • Subject: NSUInteger hash
  • From: "Steve Wart" <email@hidden>
  • Date: Sat, 16 Aug 2008 12:57:38 -0700

Hi all,

I'm just getting started with Cocoa and I'm trying to implement hash and
isEqual: methods according to the recommendations in the coding guidelines.

To implement a hash method I would normally just hash the receiver's
instance variables together and xor the result, but this only works if the
instance variables are objects.

However my instance variables are NSPoints, which are defined as structs,
not objects. The C programmer in me wants to cast the floats into integers
and hash those, but we are in a 64-bit world now, and I assume that 32-bit
algorithms may not give a good result.

Maybe I'm trying too hard, but it's important for what I'm doing that I
don't have a lot of collisions so I want a good quality hash function.

What's the standard way of hashing non-object values in Cocoa?

Thanks,
Steve
_______________________________________________

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

  • Follow-Ups:
    • Re: NSUInteger hash
      • From: "Michael Ash" <email@hidden>
    • Re: NSUInteger hash
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Window 'close' action fails
  • Next by Date: Re: Preferred Wrapper for TCP Sockets Over Local Network?
  • Previous by thread: Re: Preferred Wrapper for TCP Sockets Over Local Network?
  • Next by thread: Re: NSUInteger hash
  • Index(es):
    • Date
    • Thread