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
0a3c7cbe
Commit
0a3c7cbe
authored
Apr 11, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
aac3d27e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
all_test.go
all_test.go
+0
-1
btree.go
btree.go
+13
-13
No files found.
all_test.go
View file @
0a3c7cbe
...
...
@@ -27,7 +27,6 @@ var caller = func(s string, va ...interface{}) {
}
func
dbg
(
s
string
,
va
...
interface
{})
{
return
if
s
==
""
{
s
=
strings
.
Repeat
(
"%v "
,
len
(
va
))
}
...
...
btree.go
View file @
0a3c7cbe
...
...
@@ -673,13 +673,13 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
switch
{
case
ok
:
dbg
(
"ok'"
)
//
dbg("ok'")
dd
.
d
[
i
]
.
v
=
v
t
.
hitDi
=
i
return
case
dd
.
c
<
2
*
kd
:
dbg
(
"insert'"
)
//
dbg("insert'")
t
.
insert
(
dd
,
i
,
k
,
v
)
return
...
...
@@ -690,7 +690,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
//break
p
,
pi
:=
t
.
hitP
,
t
.
hitPi
if
p
==
nil
||
p
.
c
<=
2
*
kx
{
// XXX < vs <=
dbg
(
"overflow'"
)
//
dbg("overflow'")
t
.
overflow
(
p
,
dd
,
pi
,
i
,
k
,
v
)
return
}
...
...
@@ -702,7 +702,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
var
p
*
x
q
:=
t
.
r
if
q
==
nil
{
dbg
(
"empty"
)
//
dbg("empty")
z
:=
t
.
insert
(
btDPool
.
Get
()
.
(
*
d
),
0
,
k
,
v
)
// XXX update hit
t
.
r
,
t
.
first
,
t
.
last
=
z
,
z
,
z
return
...
...
@@ -719,21 +719,21 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
if
x
.
c
>
2
*
kx
{
//x, i = t.splitX(p, x, pi, i)
dbg
(
"splitX"
)
//
dbg("splitX")
x
,
i
,
p
,
pi
=
t
.
splitX
(
p
,
x
,
pi
,
i
)
// NOTE splitX changes p which means hit
// Kmin/Kmax/PKmax have to be recomputed
if
pi
>=
0
&&
pi
<
p
.
c
{
hitPKmax
.
set
(
p
.
x
[
pi
]
.
k
)
// XXX wrong vs oo and not oo above
dbg
(
"hitPKmax X: %v"
,
hitPKmax
)
//
dbg("hitPKmax X: %v", hitPKmax)
hitKmax
=
hitPKmax
dbg
(
"hitKmax X: %v"
,
hitKmax
)
//
dbg("hitKmax X: %v", hitKmax)
}
if
pi
>
0
{
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
// XXX also recheck vs above
dbg
(
"hitKmin X: %v"
,
hitKmin
)
//
dbg("hitKmin X: %v", hitKmin)
}
}
else
{
// p unchanged
...
...
@@ -751,12 +751,12 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
if
pi
>
0
{
// XXX also check < p.c ?
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
dbg
(
"hitKmin: %v"
,
hitKmin
)
//
dbg("hitKmin: %v", hitKmin)
}
if
pi
<
p
.
c
{
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
dbg
(
"hitKmax: %v"
,
hitKmax
)
//
dbg("hitKmax: %v", hitKmax)
}
...
...
@@ -770,16 +770,16 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
switch
{
case
ok
:
dbg
(
"ok"
)
//
dbg("ok")
x
.
d
[
i
]
.
v
=
v
t
.
hitD
,
t
.
hitDi
=
x
,
i
case
x
.
c
<
2
*
kd
:
dbg
(
"insert"
)
//
dbg("insert")
t
.
insert
(
x
,
i
,
k
,
v
)
default
:
dbg
(
"overflow"
)
//
dbg("overflow")
// NOTE overflow will correct hit Kmin, Kmax, P and Pi as needed
t
.
overflow
(
p
,
x
,
pi
,
i
,
k
,
v
)
}
...
...
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