• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Collection classes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Collection classes (From: T Reaves <email@hidden>)
 >Re: Collection classes (From: Todd Blanchard <email@hidden>)
 >Re: Collection classes (From: Dustin Voss <email@hidden>)
 >Re: Collection classes (From: Kyle Moffett <email@hidden>)

  • Prev by Date: Re: NSTableHeaderView and NSTableView problem...
  • Next by Date: Re: NSTableHeaderView and NSTableView problem...
  • Previous by thread: Re: Collection classes
  • Next by thread: Re: Collection classes
  • Index(es):
    • Date
    • Thread