Re: NSDictionary
Re: NSDictionary
- Subject: Re: NSDictionary
- From: Ricky Sharp <email@hidden>
- Date: Tue, 29 Jan 2002 20:34:19 -0600
On Tuesday, January 29, 2002, at 07:06 PM, Bob Savage wrote:
on 1/29/02 5:53 PM, John C. Randolph wrote:
What's the max size for NSDictionary/NSMutableDictionary? How many
rows/records and columns/fields?
Good question. I don't think there's a hard limit. I've had
NSMutableDictionaries with thousands of entries, but I've never
tried pushing it till it broke.
What are you proposing to store in this very large dictionary?
Aagh! I never thought of this. 8-O I might need something several
orders of
magnitude larger (e.g. 4,194,304 entries). I was going to use this as a
place to store spaces in a game I am working on. It is a strategy game
(based on a hexagonal grid) and I am storing the hex objects in a
dictionary
with their location (x, y) as the key. It is very common for me to need
to
look up a hex based on location, so this is quite ideal. Each hex has a
handful of properties: the location (NSPoint), elevation (float), an
array
of occupants (id), and a terrain (id).
But you could do something very similar with say a couple of graphic
images where the grayscale value could determine elevation. There are
many many other ways to store these things and it all will depend upon
speed vs. space.
If I am doing something very wrong here, please let me know now, so I
have a
chance to fix things before it becomes too late.
You may want to write some test apps that can fully "abuse" the
NSMutableDictionary objects. I don't think they were intended for
large-scale databases or game-world containers. I could be wrong.
e.g. the resource fork of a file is like a mini-database (which does
have a limit of 2727 resources). The old Inside Mac volumes mentioned
not to assume you'll get good speed in retrieving resources if you have
close to the max. This was because a "poor-man's search" was used to
find resources.
Only Apple knows the exact implementation of
NSMutableDictionary...perhaps it is performance-tuned to be scalable.
Maybe it uses a nice hash algorithm to provide for O(1) performance.
Speaking of which, would be cool to see such Big-O ratings for the
various container objects :)
Definitely write up that test app and run a profiler (like Sampler)
against it.
___________________________________________________________
Ricky A. Sharp
mailto:email@hidden
Founder & President
Instant Interactive(tm)
http://www.instantinteractive.com