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

Re: NSUInteger hash


  • Subject: Re: NSUInteger hash
  • From: "Steve Wart" <email@hidden>
  • Date: Sun, 17 Aug 2008 09:43:09 -0700

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 an NSMutableArray. Every wall has a start point and an
end point and exists in exactly one room. So the common wall separating a
pair of rooms is actually represented by two walls.

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.
When I have only one room left, it means that the maze is complete.

I depend on isEqualTo: to compare the walls. They are both created from the
same set of points but they are different objects, so I can't use an
identity comparison. The Smalltalk code is reasonably clean but it's
bloating unpleasantly in Objective C so I will probably need to take a
higher-level look at what I'm trying to accomplish. The original maze
algorithm was cribbed from C so it shouldn't be too hard to make it work :-)

Steve

On Sun, Aug 17, 2008 at 12:10 AM, Aaron Lees <email@hidden> wrote:

> What are you trying to do? It's usually a bad idea to compare floating
> point values for equality since you will run into subtle bugs to do with
> rounding. If you want to use your objects as dictionary keys it's often
> better to use a pointer equality rule instead of semantic equality. You can
> do this with NSMapTable without any overrides in your class.
_______________________________________________

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: Negm-Awad Amin <email@hidden>
    • Re: NSUInteger hash
      • From: "Michael Ash" <email@hidden>
    • Re: NSUInteger hash
      • From: "Kyle Sluder" <email@hidden>
References: 
 >NSUInteger hash (From: "Steve Wart" <email@hidden>)

  • Prev by Date: Re: How to enumerate directory contents?
  • Next by Date: Re: How to enumerate directory contents?
  • Previous by thread: Re: NSUInteger hash
  • Next by thread: Re: NSUInteger hash
  • Index(es):
    • Date
    • Thread