Commit 0d76b785 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 75192d09
...@@ -465,6 +465,7 @@ def __walkBFS(tree): # i[] of [](of _NodeInRange on each level) ...@@ -465,6 +465,7 @@ def __walkBFS(tree): # i[] of [](of _NodeInRange on each level)
assert isinstance(tree, Tree) assert isinstance(tree, Tree)
currentq = [] currentq = []
nextq = [_NodeInRange(_Range(-inf,+inf), tree)] nextq = [_NodeInRange(_Range(-inf,+inf), tree)]
while len(nextq) > 0: while len(nextq) > 0:
yield tuple(nextq) yield tuple(nextq)
currentq = nextq currentq = nextq
...@@ -476,6 +477,7 @@ def __walkBFS(tree): # i[] of [](of _NodeInRange on each level) ...@@ -476,6 +477,7 @@ def __walkBFS(tree): # i[] of [](of _NodeInRange on each level)
v = (rn.range.klo,) + rn.node.keyv + (rn.range.khi,) v = (rn.range.klo,) + rn.node.keyv + (rn.range.khi,)
rv = zip(v[:-1], v[1:]) # (klo,k1), (k1,k2), ..., (kN,khi) rv = zip(v[:-1], v[1:]) # (klo,k1), (k1,k2), ..., (kN,khi)
assert len(rv) == len(rn.node.children) assert len(rv) == len(rn.node.children)
for i in range(len(rv)): for i in range(len(rv)):
nextq.append(_NodeInRange(_Range(*rv[i]), rn.node.children[i])) nextq.append(_NodeInRange(_Range(*rv[i]), rn.node.children[i]))
...@@ -487,13 +489,16 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level) ...@@ -487,13 +489,16 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level)
zbucketType = ztreeType._bucket_type zbucketType = ztreeType._bucket_type
currentq = [] currentq = []
nextq = [ztree] nextq = [_NodeInRange(_Range(-inf,+inf), ztree)]
while len(nextq) > 0: while len(nextq) > 0:
yield tuple(nextq) yield tuple(nextq)
currentq = nextq currentq = nextq
nextq = [] nextq = []
while len(currentq) > 0: while len(currentq) > 0:
znode = currentq.pop(0) rn = currentq.pop(0)
znode = rn.node
ztype = _zclassify(znode) ztype = _zclassify(znode)
assert ztype.is_ztree or ztype.is_zbucket assert ztype.is_ztree or ztype.is_zbucket
...@@ -503,7 +508,7 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level) ...@@ -503,7 +508,7 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level)
if ztype.is_ztree: if ztype.is_ztree:
assert type(znode) is ztreeType assert type(znode) is ztreeType
kind, keys, kids = zbcheck.crack_btree(znode, ztype.is_map) kind, keyv, kids = zbcheck.crack_btree(znode, ztype.is_map)
if kind == zbcheck.BTREE_EMPTY: if kind == zbcheck.BTREE_EMPTY:
b = znode._bucket_type() b = znode._bucket_type()
children = [b] children = [b]
...@@ -519,8 +524,12 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level) ...@@ -519,8 +524,12 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level)
else: else:
panic("bad tree kind %r" % kind) panic("bad tree kind %r" % kind)
nextq += children v = [rn.range.klo] + keyv + [rn.range.khi]
rv = zip(v[:-1], v[1:]) # (klo,k1), (k1,k2), ..., (kN,khi)
assert len(rv) == len(children)
for i in range(len(rv)):
nextq.append(_NodeInRange(_Range(*rv[i]), children))
# TopoDecode decodes topology-encoded text into Tree structure. # TopoDecode decodes topology-encoded text into Tree structure.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment