Searching an NSArray for objects in NSDictionary
Searching an NSArray for objects in NSDictionary
- Subject: Searching an NSArray for objects in NSDictionary
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 5 Oct 2004 09:31:31 -0600
I checked the archives, but didn't see any answers to a problem I've
encountered...
I have an NSArray containing NSDictionary objects. I have several
methods that search the array given an object that may be inside one of
these NSDictionary objects, and these methods need to return an object
(or, in some methods, the index of the dictionary) that's under a
different key inside the matching NSDictionary.
Right now I'm doing a brute force search for the matching NSDictionary,
but I realize this is inefficient and I'm looking for methods of making
this search process more efficient. Normally I would try sorting the
array and doing a binary search, but these dictionaries have two
different & incompatible identifiers. So the only way I could get a
binary search to work would be to create two similar arrays that are
sorted differently, and I'm not sure if that would be an improvement,
since it would take two sort operations and consume more memory.
Can anyone suggest a better way of tackling this problem?
Nick Zitzmann
<
http://www.chronosnet.com/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden