NSDictionary, NSArray, NSSet and efficiency

Posted by ryyst on Stack Overflow See other posts from Stack Overflow or by ryyst
Published on 2010-04-24T09:31:25Z Indexed on 2010/04/24 9:33 UTC
Read the original article Hit count: 314

Filed under:
|
|
|

Hi,

I've got a text file, with about 200,000 lines. Each line represents an object with multiple properties. I only search through one of the properties (the unique ID) of the objects. If the unique ID I'm looking for is the same as the current object's unique ID, I'm gonna read the rest of the object's values.

Right now, each time I search for an object, I just read the whole text file line by line, create an object for each line and see if it's the object I'm looking for - which is basically the most inefficient way to do the search. I would like to read all those objects into memory, so I can later search through them more efficiently.

The question is, what's the most efficient way to perform such a search? Is a 200,000-entries NSArray a good way to do this (I doubt it)? How about an NSSet? With an NSSet, is it possible to only search for one property of the objects?

Thanks for any help!

-- Ry

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about nsdictionary