kdtree.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:pytorch-nec 作者: mjacar 项目源码 文件源码
def level_order(tree, include_all=False):
    """ Returns an iterator over the tree in level-order
    If include_all is set to True, empty parts of the tree are filled
    with dummy entries and the iterator becomes infinite. """

    q = deque()
    q.append(tree)
    while q:
        node = q.popleft()
        yield node

        if include_all or node.left:
            q.append(node.left or node.__class__())

        if include_all or node.right:
            q.append(node.right or node.__class__())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号