Re: Dictionary or Array?
Re: Dictionary or Array?
- Subject: Re: Dictionary or Array?
- From: Marco Binder <email@hidden>
- Date: Fri, 13 Jun 2003 15:42:32 +0200
Am Freitag, 13.06.03, um 14:50 Uhr (Europe/Berlin) schrieb Lorenzo:
Is there a way to get "a pointer" to the vertical "names" array?
I dont think what you ask for is possible. I cant imagine how that
should work. Your dictionary is mutable, so there is no guarantee for
the existence of any key. If you KNOW that all records have the same
fields, then you could use a second array, which would probably be
considerably faster because it wouldnt have to do the lookup in the
keys-table. Still, you could never get a pointer to any such "vertical
array", obviously, simply because the values will not be arranged in
line in memory (they belong to distinct arrays, remember?).
Enumeration will be the best approach for your case.
And up above it's not dynamic because if
the user adds a record or modifies a record, I have to rebuild the
"names"
array list.
Well, it would be kind of dynamic. The values you store in your name
array are only pointers to the NSMutableString values in your record
arrays (given you use mutable strings and do not generate a new
NSString instance evry time the user modifies an entry).
I thought to rebuild the database using a vertical NSMutableArray for
each
field. Then in order to get a record I should iterate through the
fields.
name = [namesArray objectAtIndex:2];
surname = [surnamesArray objectAtIndex:2];
You can do that. But then you have to ensure that all field arrays
contain the same number of entries. You ll have to add an empty string
if the field is blank for a given record. Then it would work.
Still, i m not sure whether your concerns about performance are
reasonable. How many records would you have? why would you need all the
names in a single array? If it is for display purposes only, I really
doubt performance would be a factor, if e.g. a table view would query
you for the values, would it?!
Marco
--
|\ /| email@hidden
http://www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.