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
2720e9af
Commit
2720e9af
authored
Apr 13, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
90c38231
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
btree.go
btree.go
+17
-15
No files found.
btree.go
View file @
2720e9af
...
@@ -394,11 +394,11 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
...
@@ -394,11 +394,11 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
pi
=
i
pi
=
i
q
=
x
.
x
[
pi
]
.
ch
q
=
x
.
x
[
pi
]
.
ch
if
pi
>
0
{
// k=-∞ @
pi=
-1
if
pi
>
0
{
// k=-∞ @-1
t
.
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
t
.
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
}
}
if
pi
<
p
.
c
{
// k=+∞ @
pi=
p.c
if
pi
<
p
.
c
{
// k=+∞ @p.c
t
.
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
t
.
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
}
}
...
@@ -626,7 +626,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
...
@@ -626,7 +626,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
t
.
insert
(
q
,
i
-
1
,
k
,
v
)
t
.
insert
(
q
,
i
-
1
,
k
,
v
)
p
.
x
[
pi
-
1
]
.
k
=
q
.
d
[
0
]
.
k
p
.
x
[
pi
-
1
]
.
k
=
q
.
d
[
0
]
.
k
t
.
hitKmin
.
set
(
q
.
d
[
0
]
.
k
)
t
.
hitKmin
.
set
(
q
.
d
[
0
]
.
k
)
t
.
hitPi
=
pi
// XXX
already pre-set this way
//t.hitPi = pi
already pre-set this way
return
return
}
}
...
@@ -636,7 +636,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
...
@@ -636,7 +636,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
t
.
insert
(
q
,
i
,
k
,
v
)
t
.
insert
(
q
,
i
,
k
,
v
)
p
.
x
[
pi
]
.
k
=
r
.
d
[
0
]
.
k
p
.
x
[
pi
]
.
k
=
r
.
d
[
0
]
.
k
t
.
hitKmax
.
set
(
r
.
d
[
0
]
.
k
)
t
.
hitKmax
.
set
(
r
.
d
[
0
]
.
k
)
t
.
hitPi
=
pi
// XXX
already pre-set this way
//t.hitPi = pi
already pre-set this way
return
return
}
}
...
@@ -645,7 +645,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
...
@@ -645,7 +645,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
t
.
hitKmin
.
set
(
k
)
t
.
hitKmin
.
set
(
k
)
t
.
hitKmax
=
t
.
hitPKmax
t
.
hitKmax
=
t
.
hitPKmax
if
pi
+
1
<
p
.
c
{
//
means < ∞
if
pi
+
1
<
p
.
c
{
//
k=+∞ @p.c
t
.
hitKmax
.
set
(
p
.
x
[
pi
+
1
]
.
k
)
t
.
hitKmax
.
set
(
p
.
x
[
pi
+
1
]
.
k
)
}
}
t
.
hitPi
=
pi
+
1
t
.
hitPi
=
pi
+
1
...
@@ -737,6 +737,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
...
@@ -737,6 +737,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
default
:
default
:
p
,
pi
:=
t
.
hitP
,
t
.
hitPi
p
,
pi
:=
t
.
hitP
,
t
.
hitPi
if
p
==
nil
||
p
.
c
<=
2
*
kx
{
if
p
==
nil
||
p
.
c
<=
2
*
kx
{
// XXX note on overflow corrects what
t
.
overflow
(
p
,
dd
,
pi
,
i
,
k
,
v
)
t
.
overflow
(
p
,
dd
,
pi
,
i
,
k
,
v
)
return
return
}
}
...
@@ -765,7 +766,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
...
@@ -765,7 +766,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
}
}
if
x
.
c
>
2
*
kx
{
if
x
.
c
>
2
*
kx
{
// NOTE splitX
will correct ... XXX do we need this comment ?
// NOTE splitX
corrects hit Kmin and Kmax as needed
x
,
i
=
t
.
splitX
(
p
,
x
,
pi
,
i
)
x
,
i
=
t
.
splitX
(
p
,
x
,
pi
,
i
)
}
}
...
@@ -776,11 +777,11 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
...
@@ -776,11 +777,11 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
pi
=
i
pi
=
i
q
=
p
.
x
[
pi
]
.
ch
q
=
p
.
x
[
pi
]
.
ch
if
pi
>
0
{
// k=-∞ @
pi=
-1
if
pi
>
0
{
// k=-∞ @-1
t
.
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
t
.
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
}
}
if
pi
<
p
.
c
{
// k=+∞ @
pi=
p.c
if
pi
<
p
.
c
{
// k=+∞ @p.c
t
.
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
t
.
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
}
}
...
@@ -798,7 +799,8 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
...
@@ -798,7 +799,8 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
t
.
insert
(
x
,
i
,
k
,
v
)
t
.
insert
(
x
,
i
,
k
,
v
)
default
:
default
:
// NOTE overflow will correct hit Kmin, Kmax, P and Pi as needed
// NOTE overflow corrects hit Kmin, Kmax and Pi as needed
// XXX if split
t
.
overflow
(
p
,
x
,
pi
,
i
,
k
,
v
)
t
.
overflow
(
p
,
x
,
pi
,
i
,
k
,
v
)
}
}
...
@@ -921,21 +923,21 @@ func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /
...
@@ -921,21 +923,21 @@ func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /
pi
=
0
pi
=
0
t
.
r
=
p
t
.
r
=
p
t
.
hitP
=
p
t
.
hitP
=
p
t
.
hitPi
=
pi
}
}
if
i
>
kd
{
if
i
>
kd
{
t
.
insert
(
r
,
i
-
kd
,
k
,
v
)
t
.
insert
(
r
,
i
-
kd
,
k
,
v
)
t
.
hitKmin
.
set
(
p
.
x
[
pi
]
.
k
)
t
.
hitKmin
.
set
(
p
.
x
[
pi
]
.
k
)
k
max
:=
t
.
hitPKmax
t
.
hitK
max
:=
t
.
hitPKmax
if
pi
+
1
<
p
.
c
{
if
pi
+
1
<
p
.
c
{
// k=+∞ @p.c
k
max
.
set
(
p
.
x
[
pi
+
1
]
.
k
)
t
.
hitK
max
.
set
(
p
.
x
[
pi
+
1
]
.
k
)
}
}
t
.
hitKmax
=
kmax
t
.
hitPi
=
pi
+
1
t
.
hitPi
=
pi
+
1
}
else
{
}
else
{
t
.
insert
(
q
,
i
,
k
,
v
)
t
.
insert
(
q
,
i
,
k
,
v
)
t
.
hitKmax
.
set
(
r
.
d
[
0
]
.
k
)
t
.
hitKmax
.
set
(
r
.
d
[
0
]
.
k
)
t
.
hitPi
=
pi
// XXX already pre-set so
//t.hitPi = pi already pre-set this way
}
}
}
}
...
@@ -962,7 +964,7 @@ func (t *Tree) splitX(p *x, q *x, pi int, i int) (*x, int) {
...
@@ -962,7 +964,7 @@ func (t *Tree) splitX(p *x, q *x, pi int, i int) (*x, int) {
i
-=
kx
+
1
i
-=
kx
+
1
t
.
hitKmin
.
set
(
p
.
x
[
pi
]
.
k
)
t
.
hitKmin
.
set
(
p
.
x
[
pi
]
.
k
)
t
.
hitKmax
=
t
.
hitPKmax
t
.
hitKmax
=
t
.
hitPKmax
if
pi
+
1
<
p
.
c
{
//
means < ∞
if
pi
+
1
<
p
.
c
{
//
k=+∞ @p.c
t
.
hitKmax
.
set
(
p
.
x
[
pi
+
1
]
.
k
)
t
.
hitKmax
.
set
(
p
.
x
[
pi
+
1
]
.
k
)
}
}
}
else
{
}
else
{
...
...
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