Re: Dictionary or Array?
Re: Dictionary or Array?
- Subject: Re: Dictionary or Array?
- From: zauhar <email@hidden>
- Date: Fri, 13 Jun 2003 09:11:49 -0400
Lorenzo, if you are always going to have the same set of fields, then
you really don't need a dictionary, and array access should be a lot
faster. If you intend to add new fields in an arbitrary way, but a
subset of these will always be fixed, then I think your hybrid scheme
is fine, since NSMutable array allows you to insert/remove elements at
any index.
Maybe someone else will propose a more elegant solution.
Randy
On Friday, June 13, 2003, at 08:50 AM, Lorenzo wrote:
Hi list,
I have a small database I created using a NSMutableArray of
NSMutableDictionary records.
e.g. If I need to get the field "name" of the record number 2 I do:
name = [[databaseArray objectAtIndex:2] objectForKey:@"name"];
Now I would like to get a pointer to the array containing all the
entries
for the field "name" in order to get the list of all the "names" in my
database;
Currently I iterate through the databaseArray and get one by one all
the
"name" entries. This requires time. 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.
Is there a way to get "a pointer" to the vertical "names" array?
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];
...
Is it a good idea?
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
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.
Randy J. Zauhar, PhD
Assoc. Prof. of Biochemistry
Director, Graduate Program in Bioinformatics
Dept. of Chemistry & Biochemistry
University of the Sciences in Philadelphia
600 S. 43rd Street
Philadelphia, PA 19104
Phone: (215)596-8691
FAX: (215)596-8543
E-mail: email@hidden
Web:
http://tonga.usip.edu/zauhar
Discussion after watching Disney's "Lilo & Stitch":
DAD: "But why did the space aliens speak English, as opposed to French,
or Swahili? And why did the one alien speak English with an Eastern
European accent? I don't get it."
CATHERINE (age 7): "That's 'cause you don't have a good cartoon brain."
_______________________________________________
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.