Commit f59124e0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a64f6f45
......@@ -155,8 +155,27 @@ def iterAllStructPermutations(keys, maxdepth, maxsplit):
def _iterAllStructPermutations(keyv, maxdepth, maxsplit):
def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit):
assert klo <= khi
# XXX assert keyv sorted, in [klo, khi)
for nsplit in range(0, maxsplit):
for ksplitv in _iterSplitByN(klo, khi, nsplit)
# child_i
xlo, xhi
# just Tree + Buckets
children = []
for xlo, xhi in ...:
children.append(Bucket(*_keyvSliceBy(keyv, xlo, xhi)))
yield Tree(ksplitv, children) # FIXME ksplitv wo klo/khi
# Tree + ...(Trees) + Buckets
Tree(ksplitv, _) # FIXME ksplitv w/o klo, khi
maxdepth=maxdepth-1
# _keyvSliceBy returns [] of keys from keyv : k ∈ [klo, khi)
......@@ -165,10 +184,14 @@ def _keyvSliceBy(keyv, klo, khi):
assert _keyvSorted(keyv)
return list([k for k in keyv if (klo <= k < khi)])
# iterSplitBy iterates through all nsplit splitting of [lo, hi) range.
# iterSplitByN iterates through all nsplit splitting of [lo, hi) range.
# hi > lo
# XXX nsplit > ...
def iterSplitBy(lo, hi, nsplit): # -> [] of [lo, s1, s2, ..., sn, hi)
# lo <= si < hi
# si < s_{i+1}
#
# XXX remove lo and hi from the output?
def iterSplitByN(lo, hi, nsplit): # -> [] of [lo, s1, s2, ..., sn, hi)
if nsplit == 0:
yield [lo, hi]
return
......
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