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
7750ff3f
Commit
7750ff3f
authored
May 01, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
986ff81d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+12
-3
No files found.
wcfs/internal/xbtree.py
View file @
7750ff3f
...
...
@@ -34,6 +34,7 @@ from __future__ import print_function, absolute_import
from
BTrees
import
check
as
bcheck
from
golang
import
panic
import
re
inf
=
float
(
'inf'
)
# Tree represents a tree node.
...
...
@@ -41,8 +42,8 @@ class Tree:
# .keyv () of keys
# .children () of children len(.children) == len(.keyv) + 1
def
__init__
(
t
,
keyv
,
*
children
):
assert
len
(
children
)
==
len
(
keyv
)
+
1
,
(
keyv
,
children
)
# XXX empty tree
# XXX assert keyv ↑
assert
len
(
children
)
==
len
(
keyv
)
+
1
,
(
keyv
,
children
)
_assertIncv
(
keyv
)
# XXX assert children keys consistent?
# XXX assert all children are of the same type
t
.
keyv
=
tuple
(
keyv
)
...
...
@@ -69,7 +70,7 @@ class Tree:
class
Bucket
:
# .keyv () of keys
def
__init__
(
b
,
*
keyv
):
# XXX *keyv -> keyv ?
# XXX assert keyv ↑
_assertIncv
(
keyv
)
b
.
keyv
=
tuple
(
keyv
)
def
__eq__
(
a
,
b
):
...
...
@@ -136,3 +137,11 @@ def _indent(prefix, text): # -> text
textv
=
[
prefix
+
_
for
_
in
textv
]
text
=
'
\
n
'
.
join
(
textv
)
return
text
# _assertIncv asserts that values of vector v are strictly ↑
def
_assertIncv
(
v
):
prev
=
-
inf
for
i
in
range
(
len
(
v
)):
if
not
(
v
[
i
]
>
prev
):
panic
(
"assert incv: [%d] not ↑: %s -> %s"
%
(
i
,
v
[
i
],
prev
))
prev
=
v
[
i
]
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