• 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: Negm-Awad Amin <email@hidden>
  • Date: Mon, 18 Aug 2008 10:30:21 +0200

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. 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 think, that this is the root of the problem. Two rooms are seperated by one wall. This is the (virtual) reality. Modelling this in a different way (rooms are seperated by two "surfaces") will cause problems in many ways.

What about remodelling this struture? If you need "double attributes" for a wall like color, hasWallPaper …, which are different on each surface, yo should model it this way: One wall entity with two surface entities.

Actually you divide one thing (wall) into two things (surfaces) and get problems, to glue it together again.

Cheers,
Amin



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

Amin Negm-Awad email@hidden




_______________________________________________

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: 
 >NSUInteger hash (From: "Steve Wart" <email@hidden>)
 >Re: NSUInteger hash (From: "Steve Wart" <email@hidden>)

  • Prev by Date: Re: Changing NSTextFieldCells' editing appearance?
  • Next by Date: Right place to unobserve notifications in a document
  • Previous by thread: Re: NSUInteger hash
  • Next by thread: Re: Cocoa-dev Digest, Vol 5, Issue 1470
  • Index(es):
    • Date
    • Thread