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)
assert isinstance(tree, Tree)
currentq = []
nextq = [_NodeInRange(_Range(-inf,+inf), tree)]
while len(nextq) > 0:
yield tuple(nextq)
currentq = nextq
......@@ -476,6 +477,7 @@ def __walkBFS(tree): # i[] of [](of _NodeInRange on each level)
v = (rn.range.klo,) + rn.node.keyv + (rn.range.khi,)
rv = zip(v[:-1], v[1:]) # (klo,k1), (k1,k2), ..., (kN,khi)
assert len(rv) == len(rn.node.children)
for i in range(len(rv)):
nextq.append(_NodeInRange(_Range(*rv[i]), rn.node.children[i]))
......@@ -487,13 +489,16 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level)
zbucketType = ztreeType._bucket_type
currentq = []
nextq = [ztree]
nextq = [_NodeInRange(_Range(-inf,+inf), ztree)]
while len(nextq) > 0:
yield tuple(nextq)
currentq = nextq
nextq = []
while len(currentq) > 0:
znode = currentq.pop(0)
rn = currentq.pop(0)
znode = rn.node
ztype = _zclassify(znode)
assert ztype.is_ztree or ztype.is_zbucket
......@@ -503,7 +508,7 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level)
if ztype.is_ztree:
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:
b = znode._bucket_type()
children = [b]
......@@ -519,8 +524,12 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level)
else:
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.
......
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