Commit ca32f0c0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f59124e0
......@@ -33,6 +33,7 @@ from __future__ import print_function, absolute_import
from BTrees import check as bcheck
from golang import panic
import itertools
import re
inf = float('inf')
......@@ -46,6 +47,7 @@ class Tree:
_assertIncv(keyv)
# XXX assert children keys consistent?
# XXX assert all children are of the same type
# XXX assert type(child) is Tree | Bucket
t.keyv = tuple(keyv)
t.children = tuple(children)
......@@ -150,9 +152,7 @@ def iterAllStructPermutations(keys, maxdepth, maxsplit):
klo = keyv[0] - 1
khi = keyv[-1] + 1 + 1 # hi is ")", not "]"
_keyvSliceBy(keyv, klo, khi)
yield from _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit)
def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit):
......@@ -172,10 +172,16 @@ def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit):
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
if maxdepth == 0:
continue
ichildren = [] # of _iterAllStructPermutations for each child link
for xlo, xhi in ...:
ichildren.append( _iterAllStructPermutations(
xlo, xhi, _keyvSliceBy(keyv, xlo, xhi), maxdepth - 1, maxsplit))
for children in itertools.product(ichildren):
yield Tree(ksplitv, *children) # FIXME ksplitv w/o klo, khi
# _keyvSliceBy returns [] of keys from keyv : k ∈ [klo, khi)
......
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