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
43d424f6
Commit
43d424f6
authored
Apr 13, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0913c384
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
all_test.go
all_test.go
+12
-10
No files found.
all_test.go
View file @
43d424f6
...
@@ -146,7 +146,8 @@ const (
...
@@ -146,7 +146,8 @@ const (
opDel
opDel
)
)
// rescan t from root and check that hit D, P, Kmin/Kmax and rest all match what they should
// checkHit rescans t from root and checks that hit D, P, Kmin/Kmax and rest all match what they should
// it can be used after Set/Put/Delete to verify consistency
func
(
t
*
Tree
)
checkHit
(
k
interface
{}
/*K*/
,
op
treeOp
)
{
func
(
t
*
Tree
)
checkHit
(
k
interface
{}
/*K*/
,
op
treeOp
)
{
wrong
:=
false
wrong
:=
false
bad
:=
func
(
s
string
,
va
...
interface
{})
{
bad
:=
func
(
s
string
,
va
...
interface
{})
{
...
@@ -164,9 +165,9 @@ func (t *Tree) checkHit(k interface{} /*K*/, op treeOp) {
...
@@ -164,9 +165,9 @@ func (t *Tree) checkHit(k interface{} /*K*/, op treeOp) {
var
hitPKmin
,
hitPKmax
xkey
var
hitPKmin
,
hitPKmax
xkey
loop
:
loop
:
// here he tree is immutable while we are rescanning it, which means
// here
t
he tree is immutable while we are rescanning it, which means
// the logic to get hitKmin/hitKmax & friends is
simpler compared to
// the logic to get hitKmin/hitKmax & friends is
much simpler compared
// t
hat in Set when splitX may occur
r.
// t
o that in Set and Delete when e.g. splitX and underflowX may occu
r.
for
{
for
{
// empty tree
// empty tree
if
q
==
nil
{
if
q
==
nil
{
...
@@ -179,13 +180,14 @@ loop:
...
@@ -179,13 +180,14 @@ loop:
hitPKmin
=
hitKmin
hitPKmin
=
hitKmin
hitPKmax
=
hitKmax
hitPKmax
=
hitKmax
p
=
x
pi
=
i
if
ok
{
if
ok
{
p
i
++
i
++
}
}
p
=
x
pi
=
i
q
=
p
.
x
[
pi
]
.
ch
q
=
p
.
x
[
pi
]
.
ch
if
pi
>
0
{
if
pi
>
0
{
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
...
@@ -215,7 +217,7 @@ loop:
...
@@ -215,7 +217,7 @@ loop:
bad
(
"key %v found after delete"
,
k
)
bad
(
"key %v found after delete"
,
k
)
}
}
// delted last element or tried to delete element past max k in x
// del
e
ted last element or tried to delete element past max k in x
if
i
>=
x
.
c
{
if
i
>=
x
.
c
{
i
=
x
.
c
-
1
i
=
x
.
c
-
1
}
}
...
@@ -234,11 +236,11 @@ loop:
...
@@ -234,11 +236,11 @@ loop:
bad
(
"hitPK mismatch: [%v, %v) ; want [%v, %v)"
,
t
.
hitPKmin
,
t
.
hitPKmax
,
hitPKmin
,
hitPKmax
)
bad
(
"hitPK mismatch: [%v, %v) ; want [%v, %v)"
,
t
.
hitPKmin
,
t
.
hitPKmax
,
hitPKmin
,
hitPKmax
)
}
}
if
dd
!=
t
.
hitD
||
i
!=
t
.
hitDi
{
if
!
(
dd
==
t
.
hitD
&&
i
==
t
.
hitDi
)
{
bad
(
"hitD mismatch: %v @%d ; want %v @%d"
,
t
.
hitD
,
t
.
hitDi
,
dd
,
i
)
bad
(
"hitD mismatch: %v @%d ; want %v @%d"
,
t
.
hitD
,
t
.
hitDi
,
dd
,
i
)
}
}
if
p
!=
t
.
hitP
||
pi
!=
t
.
hitPi
{
if
!
(
p
==
t
.
hitP
&&
pi
==
t
.
hitPi
)
{
bad
(
"hitP mismatch: %v @%d ; want %v @%d"
,
t
.
hitP
,
t
.
hitPi
,
p
,
pi
)
bad
(
"hitP mismatch: %v @%d ; want %v @%d"
,
t
.
hitP
,
t
.
hitPi
,
p
,
pi
)
}
}
...
...
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