Commit e3e6a8e4 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 477429b3
......@@ -132,6 +132,7 @@ class Tree(object):
__repr__ = __str__
# copy returns a deep copy of the tree.
def copy(t):
return Tree(t.keyv, *[_.copy() for _ in t.children])
......@@ -225,23 +226,28 @@ def Restructure(ztree, newStructure):
# D(A,B) = ────────────── + ──────────────
# N(A) N(B)
#
# we will modify nodes from new set:
# - node.Z will point to associated znode
# - bucket.next_bucket will point to bucket that is coming next in the tree
tnew = newStructure.copy()
zlevelv = list(_zwalkBFS(ztree))
levelv = list( _walkBFS(tnew))
# assotiate every node in tnew to a znode
# XXX check for end
zlevel = zlevelv.pop(0)
level = levelv.pop(0)
if len(zlevel) == len(level): # map 1-1
for (znode, node) in zip(zlevel, level):
node.Z = znode
else:
panic("TODO")
while len(levelv) > 0:
# XXX check for end
level = levelv.pop(0)
if len(zlevelv) == 0:
panic("TODO")
zlevel = zlevelv.pop(0)
if len(zlevel) == len(level): # map 1-1
for (znode, node) in zip(zlevel, level):
node.Z = znode
else:
panic("TODO")
# set znode states according to established tnew->znode association
......
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