• 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: NSOutlineView: removing the selected items, what's the easy way?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOutlineView: removing the selected items, what's the easy way?


  • Subject: Re: NSOutlineView: removing the selected items, what's the easy way?
  • From: Itrat Khan <email@hidden>
  • Date: Mon, 8 Jul 2002 17:20:21 -0400

On Monday, July 8, 2002, at 04:41 PM, Allan Odgaard wrote:

Using the enumerator method I get the indices of the selected rows, but these indices refer to the visible index, and thus vary depending on the which items are collapsed/expanded.

Either I go through the NSOutlineView's items while also traversing my own datastructure, and remove items when I find a match (O(n) granted the enumerator outputs the indices in ascending order), or I convert the indices to item pointers and search for each (O(m*n) where m is the number of selected items) -- I need to search because it's a hierarchical datastructure -- alternatively I could tag each item with it's parent, so that it coudl be removed without the search, but I dislike this overhead.


There's nothing dirty in tagging each item with its parent, like asking a view for its superview. Also converting indices to pointers remains O(n), since you are simply iterating through n items twice (once to get the pointers, and once more to tell each item to remove itself). This is probably your best approach; the first approach of traversing your data structure as you enumerate over rows requires O(n^2) time and should be avoided.

Itrat.

............................................................
Modeless Software, Inc.
London, Ontario (Canada)
Tel: +1 519 473 2037
Web: www.modeless.com
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSOutlineView: removing the selected items, what's the easy way?
      • From: Allan Odgaard <email@hidden>
References: 
 >NSOutlineView: removing the selected items, what's the easy way? (From: Allan Odgaard <email@hidden>)

  • Prev by Date: Re: Starting Cocoa development - Developing for Jaguar
  • Next by Date: Re: How to get file creation date
  • Previous by thread: NSOutlineView: removing the selected items, what's the easy way?
  • Next by thread: Re: NSOutlineView: removing the selected items, what's the easy way?
  • Index(es):
    • Date
    • Thread