Re: NSOutlineView: removing the selected items, what's the easy way?
Re: NSOutlineView: removing the selected items, what's the easy way?
- Subject: Re: NSOutlineView: removing the selected items, what's the easy way?
- From: Allan Odgaard <email@hidden>
- Date: Tue, 9 Jul 2002 09:46:13 +0200
On mandag, juli 8, 2002, at 11:20 , Itrat Khan wrote:
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.
I didnt say it was dirty, just that it has memory overhead --
furthermore I'd like the ability to read/write the datastructure from/to
XML, and that's not possible when adding these circular references, so
I'd have to add the back-pointers on read and remove them on write :-(
the first approach of traversing your data structure as you enumerate
over rows requires O(n^2) time and should be avoided.
As stated, this was assuming the indexes were ascending (which they seem
to be), so it is O(n)! If the indexes are not ascending then I could
always sort them to make it O(n log n) -- though to be exact, the time
complexity for the naive non-ascending indexes are O(n*m), where m is
the number of selected items (where m <= n, so worst case would of
course be O(n^2)).
_______________________________________________
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.