Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
b
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
b
Commits
318c5837
Commit
318c5837
authored
Apr 11, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ea98b4ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
88 deletions
+62
-88
all_test.go
all_test.go
+62
-88
No files found.
all_test.go
View file @
318c5837
...
...
@@ -140,28 +140,14 @@ func (t *Tree) dump() string {
return
s
}
// rescan t from root and check that hit D, P, Kmin/Kmax and rest all match what they should
func
(
t
*
Tree
)
checkHit
(
k
interface
{}
/*K*/
)
{
badHappenned
:=
false
wrong
:=
false
bad
:=
func
(
s
string
,
va
...
interface
{})
{
dbg
(
s
,
va
...
)
badHappenned
=
true
wrong
=
true
}
//println()
if
t
.
hitDi
>=
0
{
if
t
.
hitD
.
d
[
t
.
hitDi
]
.
k
!=
k
{
bad
(
"hitD invalid: %v @%v"
,
t
.
hitD
,
t
.
hitDi
)
}
}
if
t
.
hitPi
>=
0
{
if
t
.
hitP
.
x
[
t
.
hitPi
]
.
ch
!=
t
.
hitD
{
bad
(
"hitP invalid: %v @%v"
,
t
.
hitP
,
t
.
hitPi
)
}
}
// rescan from root and check Kmin/Kmax and rest
q
:=
t
.
r
var
p
*
x
pi
:=
-
1
...
...
@@ -172,23 +158,21 @@ func (t *Tree) checkHit(k interface{} /*K*/) {
var
hitKmin
,
hitKmax
xkey
var
hitPKmax
xkey
//dbg("k: %v", k)
loop
:
loop
:
// here he tree is immutable while we are rescanning it, which means
// the logic to get hitKmin/hitKmax & friends is simpler compared to
// that in Set when splitX may occurr.
for
{
//dbg("p: %p: @%d %v", p, pi, p)
//dbg("q: %p: %v", q, q)
i
,
ok
=
t
.
find
(
q
,
k
)
//dbg("\t-> %v, %v", i, ok)
switch
x
:=
q
.
(
type
)
{
case
*
x
:
hitPKmax
=
hitKmax
// XXX recheck
hitPKmax
=
hitKmax
p
=
x
pi
=
i
if
ok
{
pi
++
}
//dbg("\tpi -> %v", pi)
q
=
p
.
x
[
pi
]
.
ch
if
pi
>
0
{
...
...
@@ -200,9 +184,8 @@ func (t *Tree) checkHit(k interface{} /*K*/) {
}
}
if
pi
<
p
.
c
{
//dbg("", p.x, pi)
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
// XXX not sure or x[pi+1] ?
if
pi
<
p
.
c
{
// pi = p.c means k = ∞
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
if
hitPKmax
.
kset
&&
t
.
cmp
(
hitKmax
.
k
,
hitPKmax
.
k
)
>=
0
{
bad
(
"hitKmax not ↓: %v -> %v"
,
hitPKmax
.
k
,
hitKmax
.
k
)
...
...
@@ -220,12 +203,8 @@ func (t *Tree) checkHit(k interface{} /*K*/) {
}
}
if
hitKmin
!=
t
.
hitKmin
{
bad
(
"hitKmin mismatch: %v ; want %v"
,
t
.
hitKmin
,
hitKmin
)
}
if
hitKmax
!=
t
.
hitKmax
{
bad
(
"hitKmax mismatch: %v ; want %v"
,
t
.
hitKmax
,
hitKmax
)
if
!
(
hitKmin
==
t
.
hitKmin
&&
hitKmax
==
t
.
hitKmax
)
{
bad
(
"hitK mismatch: [%v, %v) ; want [%v, %v)"
,
t
.
hitKmin
,
t
.
hitKmax
,
hitKmin
,
hitKmax
)
}
if
hitPKmax
!=
t
.
hitPKmax
{
...
...
@@ -240,12 +219,7 @@ func (t *Tree) checkHit(k interface{} /*K*/) {
bad
(
"hitP mismatch: %v @%d ; want %v @%d"
,
t
.
hitP
,
t
.
hitPi
,
p
,
pi
)
}
//v2, ok := t.Get(k)
//if !ok || v2 != v {
// bad("get(%v) -> %v, %v; want %v, %v", k, v2, ok, v, true)
//}
if
badHappenned
{
if
wrong
{
panic
(
0
)
}
}
...
...
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