Re: NSUInteger hash

2008-08-18 Thread Negm-Awad Amin
Hi Steve, Am So,17.08.2008 um 18:43 schrieb Steve Wart: Hi Aaron, That's always a good question to ask. I'm porting a Smalltalk/OpenGL maze application I wrote a few years ago to Cocoa. The maze is initialized by creating a 2D matrix of Room objects which are separated by Wall objects.

Re: NSUInteger hash

2008-08-17 Thread Michael Ash
On Sun, Aug 17, 2008 at 12:43 PM, Steve Wart <[EMAIL PROTECTED]> wrote: > Hi Aaron, > > That's always a good question to ask. > > I'm porting a Smalltalk/OpenGL maze application I wrote a few years ago to > Cocoa. > > The maze is initialized by creating a 2D matrix of Room objects which are > separ

Re: NSUInteger hash

2008-08-17 Thread Kyle Sluder
On Sun, Aug 17, 2008 at 12:43 PM, Steve Wart <[EMAIL PROTECTED]> wrote: > I go through the rooms in random order, pick a wall at random, and knock it > down (also being careful to knock down the corresponding wall in any > adjacent rooms). By knocking down a wall, two rooms become merged into one.

Re: NSUInteger hash

2008-08-17 Thread Steve Wart
Hi Aaron, That's always a good question to ask. I'm porting a Smalltalk/OpenGL maze application I wrote a few years ago to Cocoa. The maze is initialized by creating a 2D matrix of Room objects which are separated by Wall objects. Every room has an ordered collection of walls which I've put into

Re: NSUInteger hash

2008-08-16 Thread Steve Wart
hem to NSUInteger, thereby truncating off the decimal bits, and then > XOR the result together: > > - (NSUInteger)hash { return (NSUInteger)p.x ^ (NSUInteger)p.y; } > > Note that this stops making much sense if you expect your points to be > fractional values, and you want dif

Re: NSUInteger hash

2008-08-16 Thread Michael Ash
ve a pair of floats. The simplest thing to do would be to cast them to NSUInteger, thereby truncating off the decimal bits, and then XOR the result together: - (NSUInteger)hash { return (NSUInteger)p.x ^ (NSUInteger)p.y; } Note that this stops making much sense if you expect your points to be

Re: NSUInteger hash

2008-08-16 Thread Nick Zitzmann
On Aug 16, 2008, at 1:57 PM, Steve Wart wrote: What's the standard way of hashing non-object values in Cocoa? Something like this ought to work: (warning - written in Mail, untested, use at your own risk) [[NSNumber numberWithUnsignedInteger:someNSUInteger] hash]; You can use NSValue to

NSUInteger hash

2008-08-16 Thread Steve Wart
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