Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
ce5ef12e
Commit
ce5ef12e
authored
May 04, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
01a821bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+9
-6
No files found.
wcfs/internal/xbtree.py
View file @
ce5ef12e
...
...
@@ -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
_iterAllStruct
Permutation
s
(
klo
,
khi
,
keyv
,
maxdepth
,
maxsplit
):
for
tree
in
_iterAllStructs
(
klo
,
khi
,
keyv
,
maxdepth
,
maxsplit
):
yield
tree
def
_iterAllStruct
Permutation
s
(
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 _iterAllStruct
Permutation
s for each child link
ichildren
=
[]
# of _iterAllStructs for each child link
for
xlo
,
xhi
in
...:
ichildren
.
append
(
_iterAllStruct
Permutation
s
(
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 ----
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment