Commit ce5ef12e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 01a821bd
...@@ -131,10 +131,12 @@ def topoEncode(treeStruct): ...@@ -131,10 +131,12 @@ def topoEncode(treeStruct):
1/0 1/0
# iterAllStructPermutation iterates though all structures for BTrees with # IterAllStructs iterates though practically all structures for BTrees with
# specified keys and btree depth up-to maxdepth. Eatch tree node is split by # specified keys and btree depth up-to maxdepth. Eatch tree node is split by
# up-to maxsplit points. # up-to maxsplit points.
def iterAllStructPermutations(keys, maxdepth, maxsplit): #
# XXX skipped cases
def IterAllStructs(keys, maxdepth, maxsplit):
assert isinstance(maxdepth, int); assert maxdepth >= 0 assert isinstance(maxdepth, int); assert maxdepth >= 0
assert isinstance(maxsplit, int); assert maxsplit >= 0 assert isinstance(maxsplit, int); assert maxsplit >= 0
ks = set(keys) ks = set(keys)
...@@ -152,11 +154,11 @@ def iterAllStructPermutations(keys, maxdepth, maxsplit): ...@@ -152,11 +154,11 @@ def iterAllStructPermutations(keys, maxdepth, maxsplit):
klo = keyv[0] - 1 klo = keyv[0] - 1
khi = keyv[-1] + 1 + 1 # hi is ")", not "]" khi = keyv[-1] + 1 + 1 # hi is ")", not "]"
for tree in _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit): for tree in _iterAllStructs(klo, khi, keyv, maxdepth, maxsplit):
yield tree yield tree
def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit): def _iterAllStructs(klo, khi, keyv, maxdepth, maxsplit):
assert klo <= khi assert klo <= khi
# XXX assert keyv sorted, in [klo, khi) # XXX assert keyv sorted, in [klo, khi)
...@@ -175,9 +177,9 @@ def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit): ...@@ -175,9 +177,9 @@ def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit):
# emit Tree -> Trees -> ... # emit Tree -> Trees -> ...
if maxdepth == 0: if maxdepth == 0:
continue continue
ichildren = [] # of _iterAllStructPermutations for each child link ichildren = [] # of _iterAllStructs for each child link
for xlo, xhi in ...: for xlo, xhi in ...:
ichildren.append( _iterAllStructPermutations( ichildren.append( _iterAllStructs(
xlo, xhi, _keyvSliceBy(keyv, xlo, xhi), maxdepth - 1, maxsplit)) xlo, xhi, _keyvSliceBy(keyv, xlo, xhi), maxdepth - 1, maxsplit))
for children in itertools.product(ichildren): for children in itertools.product(ichildren):
...@@ -203,6 +205,7 @@ def iterSplitByN(lo, hi, nsplit): # -> [] of [lo, s1, s2, ..., sn, hi) ...@@ -203,6 +205,7 @@ def iterSplitByN(lo, hi, nsplit): # -> [] of [lo, s1, s2, ..., sn, hi)
return return
# XXX # XXX
1/0
# ---- misc ---- # ---- misc ----
......
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