On Mon, Aug 14, 2023 at 12:48 AM vitalije wrote:

>> We can't use VNode generators because they don't yield VNodes in outline
order.

> I really don't know where did you get this idea from?

You're quite right. There were some brain spikes in my comments.

PR #3473 <https://github.com/leo-editor/leo-editor/pull/3473> now contains
working code. See *c.recompute_all_parents* and *c.alt_all_unique_nodes*,
both covered with unit tests. c.recompute_all_parents is surprisingly
trickly. See the comment below about the loop invariant.

def recompute_all_parents(self) -> None:
    """
    Recompute all v.parents arrays using neither positions nor v.parents
ivars.
    """
    c = self
    root_v = c.hiddenRootNode

    # Clear all v.parents arrays.
    root_v.parents = []
    for v in c.alt_all_unique_nodes():
        v.parents = []

    # Loop invariant: Visit each *parent* vnode *once*.
    #                 Child vnodes may be visited more than once.
    for child in root_v.children:
        child.parents.append(root_v)
    for parent in c.alt_all_unique_nodes():
        for child in parent.children:
            child.parents.append(parent)

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAMF8tS0z-g%3DfVJz3V18vjRDbkkinwH1baAi745BiPgTxdTCxrA%40mail.gmail.com.

Reply via email to