Commit 3e3625a7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 5c9f7ec4
...@@ -26,12 +26,16 @@ It is primarily used to verify ΔBTail in wcfs. ...@@ -26,12 +26,16 @@ It is primarily used to verify ΔBTail in wcfs.
XXX Typology: XXX Typology:
""" """
# Tree represents internal tree node. from BTrees import check as bcheck
# Tree represents a tree node.
class Tree: class Tree:
# .keyv () of keys # .keyv () of keys
# .children () of children len(.children) == len(.keyv) + 1 # .children () of children len(.children) == len(.keyv) + 1
def __init__(tree, keyv, *children): def __init__(tree, keyv, *children):
assert len(children) == len(keyv) + 1 assert len(children) == len(keyv) + 1, (keyv, children)
# XXX assert keyv ↑
# XXX assert children keys consistent?
tree.keyv = tuple(keyv) tree.keyv = tuple(keyv)
tree.children = tuple(children) tree.children = tuple(children)
...@@ -45,7 +49,20 @@ class Tree: ...@@ -45,7 +49,20 @@ class Tree:
# StructureOf returns internal structure of the tree. # StructureOf returns internal structure of the tree.
def StructureOf(tree): def StructureOf(tree):
1/0 typ = type(tree)
assert "Tree" in typ.__name__, typ
kind, keys, children = bcheck.crack_btree(tree, True)
if kind == bcheck.BTREE_EMPTY:
return Tree([])
if kind == bcheck.BTREE_ONE:
return Tree([])
if kind == bcheck.BTREE_NORMAL:
return Tree(keys, *[StructureOf(_) for _ in children])
panic("bad kind %r" % kind)
# TypologyOf returns topology encoding for internal structure of the tree. # TypologyOf returns topology encoding for internal structure of the tree.
# #
......
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