Commit f219083d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6526c4ac
......@@ -86,15 +86,21 @@ inf = float('inf')
# Tree represents a tree node.
class Tree:
class Tree(object):
# .keyv () of keys
# .children () of children len(.children) == len(.keyv) + 1
def __init__(t, keyv, *children):
assert len(children) == len(keyv) + 1, (keyv, children)
_assertIncv(keyv)
# XXX assert all children are of the same type
# XXX assert type(child) is Tree | Bucket
# XXX assert children keys consistent
if len(children) > 0:
# assert all children are of the same type
childtypes = set([type(_) for _ in children])
if len(childtypes) != 1:
panic("children are of distinct types: %s" % (childtypes,))
# assert type(child) is Tree | Bucket
childtype = childtypes.pop()
assert childtype in (Tree, Bucket), childtype
# XXX assert children keys consistent
t.keyv = tuple(keyv)
t.children = tuple(children)
......@@ -120,11 +126,9 @@ class Tree:
# return 'R'+str(t)
# TODO def graphviz() -> str for graphviz
# TODO def TopoEncode() -> str with topology encoding
# TODO @staticmethod def TopoDecode(in) <- Tree from topology string
# Bucked represents a bucket node.
class Bucket:
class Bucket(object):
# .keyv () of keys
def __init__(b, *keyv): # XXX *keyv -> keyv ?
_assertIncv(keyv)
......
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