On Tue, Aug 3, 2010 at 1:50 PM, Edward K. Ream <[email protected]> wrote:
> On Tue, Aug 3, 2010 at 1:48 PM, Ville M. Vainio <[email protected]> wrote:
>
>> We can easily prune the positions that are descendants of other
>> positions in the list before sweeping out the positions.
>>
>> I just feel that the api you suggest is quite cryptic for something
>> user feels should be a straightforward operation - delete these
>> positions from the tree c.
>
> Alright.  Let me attempt to do as you suggest.

Do you have something better than this O(N**2) algorithm?

    # Remove any items in aList whose ancestors are in aList.
    aList2 = []
    for z in aList:
        for z2 in aList:
            if z2.isAncestorOf(z):
                break
        else:
            aList2.append(z)

In general this will be fast enough because we expect small lists, but
I'm not sure that the minor convenience is worth the worst-case
behavior.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to