Re: Collection classes
Re: Collection classes
- Subject: Re: Collection classes
- From: Allan Odgaard <email@hidden>
- Date: Sat, 10 Jan 2004 02:39:43 +0100
On 9. Jan 2004, at 6:00, Kyle Moffett wrote:
[...] I need to know whether something is O(n), O(1), or whatever.
IMHO, the NSArray, NSSet, and NSDictionary classes are not exactly
designed for high performance. [...] If you run into a specific
performance problem *then* you can try to solve it [...]
We are not talking about wether the implementation is effective or not,
simply that we need to know the time complexity!
For example, to select a given set of items in a table view, we would
have to write code like this:
NSMutableIndexSet* indices = [NSMutableIndexSet indexSet];
NSEnumerator* enumerator = [itemsToSelect objectEnumerator];
while(id itemNr = [enumerator nextObject])
[indices addIndex:[itemNr intValue]];
[tableView selectRowIndexes:indices byExtendingSelection:NO];
You may test the above code with 5,000 items on a 1.25 GHz G5, and it
takes half a second, which you do not notice as a performance problem.
But if "addIndex:" is O(n) then a user with a 733 MHz G4 and 15,000
items will probably spend 10 seconds on the same procedure.
_______________________________________________
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.