Commit e3e6a8e4 authored by Kirill Smelkov's avatar Kirill Smelkov

.

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