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
1a0cfd54
Commit
1a0cfd54
authored
May 15, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3604f4a5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
51 deletions
+53
-51
wcfs/pptreesubset.go
wcfs/pptreesubset.go
+53
-51
No files found.
wcfs/pptreesubset.go
View file @
1a0cfd54
...
...
@@ -57,54 +57,6 @@ type nodeInTree struct {
}
// verify checks internal consistency of S.
func
(
S
PPTreeSubSet
)
verify
()
{
// XXX !debug -> return
var
badv
[]
string
badf
:=
func
(
format
string
,
argv
...
interface
{})
{
badv
=
append
(
badv
,
fmt
.
Sprintf
(
format
,
argv
...
))
}
defer
func
()
{
if
badv
!=
nil
{
emsg
:=
fmt
.
Sprintf
(
"S.verify: fail:
\n\n
"
)
for
_
,
bad
:=
range
badv
{
emsg
+=
fmt
.
Sprintf
(
"- %s
\n
"
,
bad
)
}
emsg
+=
fmt
.
Sprintf
(
"
\n
S: %s
\n
"
,
S
)
panic
(
emsg
)
}
}()
// recompute {} oid -> children and verify .nchild against it
children
:=
map
[
zodb
.
Oid
]
SetOid
{}
for
oid
,
t
:=
range
S
{
if
t
.
parent
!=
zodb
.
InvalidOid
{
cc
,
ok
:=
children
[
t
.
parent
]
if
!
ok
{
cc
=
SetOid
{}
children
[
t
.
parent
]
=
cc
}
cc
.
Add
(
oid
)
}
}
for
oid
,
t
:=
range
S
{
cc
:=
children
[
oid
]
if
t
.
nchild
!=
len
(
cc
)
{
badf
(
"[%s].nchild=%d children: %s"
,
oid
,
t
.
nchild
,
cc
)
}
}
// verify that all pointed-to parents are present in the set (= PP-connected)
for
oid
:=
range
children
{
_
,
ok
:=
S
[
oid
]
if
!
ok
{
badf
(
"oid %s is pointed to via some .parent, but is not present in the set"
,
oid
)
}
}
}
// Path returns path leading to node specified by oid.
//
// The node must be in the set.
...
...
@@ -348,8 +300,60 @@ func (S PPTreeSubSet) gc1(oid zodb.Oid) {
}
// ---- verify ----
// verify checks internal consistency of S.
func
(
S
PPTreeSubSet
)
verify
()
{
// XXX !debug -> return
var
badv
[]
string
badf
:=
func
(
format
string
,
argv
...
interface
{})
{
badv
=
append
(
badv
,
fmt
.
Sprintf
(
format
,
argv
...
))
}
defer
func
()
{
if
badv
!=
nil
{
emsg
:=
fmt
.
Sprintf
(
"S.verify: fail:
\n\n
"
)
for
_
,
bad
:=
range
badv
{
emsg
+=
fmt
.
Sprintf
(
"- %s
\n
"
,
bad
)
}
emsg
+=
fmt
.
Sprintf
(
"
\n
S: %s
\n
"
,
S
)
panic
(
emsg
)
}
}()
// recompute {} oid -> children and verify .nchild against it
children
:=
map
[
zodb
.
Oid
]
SetOid
{}
for
oid
,
t
:=
range
S
{
if
t
.
parent
!=
zodb
.
InvalidOid
{
cc
,
ok
:=
children
[
t
.
parent
]
if
!
ok
{
cc
=
SetOid
{}
children
[
t
.
parent
]
=
cc
}
cc
.
Add
(
oid
)
}
}
for
oid
,
t
:=
range
S
{
cc
:=
children
[
oid
]
if
t
.
nchild
!=
len
(
cc
)
{
badf
(
"[%s].nchild=%d children: %s"
,
oid
,
t
.
nchild
,
cc
)
}
}
// verify that all pointed-to parents are present in the set (= PP-connected)
for
oid
:=
range
children
{
_
,
ok
:=
S
[
oid
]
if
!
ok
{
badf
(
"oid %s is pointed to via some .parent, but is not present in the set"
,
oid
)
}
}
}
// ---- misc ----
// Clone returns copy of the set.
// XXX place
func
(
orig
PPTreeSubSet
)
Clone
()
PPTreeSubSet
{
klon
:=
make
(
PPTreeSubSet
,
len
(
orig
))
for
oid
,
t
:=
range
orig
{
...
...
@@ -359,7 +363,6 @@ func (orig PPTreeSubSet) Clone() PPTreeSubSet {
}
// equal returns whether a == b.
// XXX place
func
(
A
PPTreeSubSet
)
equal
(
B
PPTreeSubSet
)
bool
{
if
len
(
A
)
!=
len
(
B
)
{
return
false
...
...
@@ -384,7 +387,6 @@ func (t nodeInTree) String() string {
}
// ---- diff/patch ----
// ΔPPTreeSubSet represents a change to PPTreeSubSet.
...
...
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