Re: Collection classes
Re: Collection classes
- Subject: Re: Collection classes
- From: Dustin Voss <email@hidden>
- Date: Fri, 9 Jan 2004 20:40:58 -0800
On 9 Jan, 2004, at 5:36 PM, Allan Odgaard wrote:
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.
And if we knew the time complexity, we could decide which of several
alternative implementations to use. Often, we can come up with a
solution using either an NSArray or an NSSet, for example.
I'll think I'll submit this to the documenation feedback page.
_______________________________________________
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.