Re: Fast dictionary with integer keys?
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