Commit ce5ef12e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 01a821bd
......@@ -131,10 +131,12 @@ def topoEncode(treeStruct):
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
# 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(maxsplit, int); assert maxsplit >= 0
ks = set(keys)
......@@ -152,11 +154,11 @@ def iterAllStructPermutations(keys, maxdepth, maxsplit):
klo = keyv[0] - 1
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
def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit):
def _iterAllStructs(klo, khi, keyv, maxdepth, maxsplit):
assert klo <= khi
# XXX assert keyv sorted, in [klo, khi)
......@@ -175,9 +177,9 @@ def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit):
# emit Tree -> Trees -> ...
if maxdepth == 0:
continue
ichildren = [] # of _iterAllStructPermutations for each child link
ichildren = [] # of _iterAllStructs for each child link
for xlo, xhi in ...:
ichildren.append( _iterAllStructPermutations(
ichildren.append( _iterAllStructs(
xlo, xhi, _keyvSliceBy(keyv, xlo, xhi), maxdepth - 1, maxsplit))
for children in itertools.product(ichildren):
......@@ -203,6 +205,7 @@ def iterSplitByN(lo, hi, nsplit): # -> [] of [lo, s1, s2, ..., sn, hi)
return
# XXX
1/0
# ---- 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