• 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: Tommy Nordgren <email@hidden>
  • Date: Sun, 15 Mar 2009 20:18:02 +0100


On Mar 15, 2009, at 7:33 PM, 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.

The question is: is there this kind of fast int-keyed dictionary in
Cocoa or elsewhere? Thanks!
_______________________________________________

You can write your implementation file in Objective C++ , and use std::map<int,id>
Then write your header like this:
#ifdef __cplusplus
#include <map>
#endif


@interface MyClass: NSObject
{
#ifdef __cplusplus
	std::map<int,id> * mymap; //All data pointers have same size,
#else
	void *   mymap;
#endif
}

@end

Then in your implementation file initialize your pointer:
mymap = new std::map<int,id>

and use it like this:
(*mymap) [integervalue] = someid;


-----------------------------------
See the amazing new SF reel: Invasion of the man eating cucumbers from outer space.
On congratulations for a fantastic parody, the producer replies : "What parody?"


Tommy Nordgren
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


  • Follow-Ups:
    • Re: Fast dictionary with integer keys?
      • From: Joseph Kelly <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: Re: Fast dictionary with integer keys?
  • Index(es):
    • Date
    • Thread