• 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: Fast dictionary with integer keys?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast dictionary with integer keys?


  • Subject: Re: Fast dictionary with integer keys?
  • From: Peter N Lewis <email@hidden>
  • Date: Mon, 16 Mar 2009 09:55:26 +0900

At 20:33 +0200 15/3/09, Oleg Krupnov wrote:
I need to use a dictionary inside a long, time-consuming operation.
The keys of the dictionary are integers, the values are NSObjects.

I could use NSDictionary, but I don't like the overhead of creating
NSNumbers for the keys and then comparing them, where I could use
integers directly more efficiently, both by time and memory.

Given how trivial it is to use NSDictionary, personally I'd just use NSDictionary and wait until later to profile the code and see what needs to be optimized - it may turn out this long running routine doesn't run long enough to be worth optimizing, or that the time taken by NSDictionary is insignificant compared to other operations more worthy of optimization.


Or you could just use std::map, which is relatively easy to use and presumably much faster, though as yet you have no idea if you care about that speed difference.

The plus side for NSDictionary is I don't have to ask you if you are using Garbage COllection, and you don't have to ponder the memory management issues of storing NSObject*'s in a std::map.

Bottom line: get it working, then profile if needed, then optimize.

Enjoy,
   Peter.

--
     Run macros from your iPhone with Keyboard Maestro Control!
         or take a break with Derzle for your iPhone

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
Aragom Space War <http://www.stairways.com/iphone/aragom> Don't get killed!
Derzle <http://www.stairways.com/iphone/derzle> Enjoy a relaxing puzzle.
<http://www.stairways.com/>           <http://download.stairways.com/>
_______________________________________________

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: 
 >Fast dictionary with integer keys? (From: Oleg Krupnov <email@hidden>)

  • Prev by Date: Re: Fast dictionary with integer keys?
  • Next by Date: Re: Fast dictionary with integer keys?
  • Previous by thread: Re: Fast dictionary with integer keys?
  • Next by thread: Problem with emulated right click and contextual menu
  • Index(es):
    • Date
    • Thread