On Mon, Aug 14, 2023 at 7:22 AM Edward K. Ream  wrote:

> 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.

Here is c. alt_all_unique_nodes:

def alt_all_unique_nodes(self) -> Generator:
    """
    Yield all unique VNodes corresponding to c.all_positions.

    This is an equivalent (much worse) generator:

        for z in c.all_unique_positions():
            yield z.v
    """
    c = self
    seen: dict[str, bool] = {}
    to_be_visited: list[VNode] = list(reversed(c.hiddenRootNode.children))
    while to_be_visited:
        v = to_be_visited.pop()
        if v.gnx not in seen:
            seen[v.gnx] = True
            yield v
        for child in reversed(v.children):
            to_be_visited.append(child)

The "alt_" naming convention saves a lot of confusion.

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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAMF8tS0Wq8kbMKVWv-i6GUjo_K9%3DH0AgK3WsmQO0Nupue%2BOJTg%40mail.gmail.com.

Reply via email to