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) {
pi
=
i
q
=
x
.
x
[
pi
]
.
ch
if
pi
>
0
{
// k=-∞ @
pi=
-1
if
pi
>
0
{
// k=-∞ @-1
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
)
}
...
...
@@ -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
)
p
.
x
[
pi
-
1
]
.
k
=
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
}
...
...
@@ -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
)
p
.
x
[
pi
]
.
k
=
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
}
...
...
@@ -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
.
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
.
hitPi
=
pi
+
1
...
...
@@ -737,6 +737,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
default
:
p
,
pi
:=
t
.
hitP
,
t
.
hitPi
if
p
==
nil
||
p
.
c
<=
2
*
kx
{
// XXX note on overflow corrects what
t
.
overflow
(
p
,
dd
,
pi
,
i
,
k
,
v
)
return
}
...
...
@@ -765,7 +766,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
}
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
)
}
...
...
@@ -776,11 +777,11 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
pi
=
i
q
=
p
.
x
[
pi
]
.
ch
if
pi
>
0
{
// k=-∞ @
pi=
-1
if
pi
>
0
{
// k=-∞ @-1
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
)
}
...
...
@@ -798,7 +799,8 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
t
.
insert
(
x
,
i
,
k
,
v
)
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
)
}
...
...
@@ -921,21 +923,21 @@ func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /
pi
=
0
t
.
r
=
p
t
.
hitP
=
p
t
.
hitPi
=
pi
}
if
i
>
kd
{
t
.
insert
(
r
,
i
-
kd
,
k
,
v
)
t
.
hitKmin
.
set
(
p
.
x
[
pi
]
.
k
)
k
max
:=
t
.
hitPKmax
if
pi
+
1
<
p
.
c
{
k
max
.
set
(
p
.
x
[
pi
+
1
]
.
k
)
t
.
hitK
max
:=
t
.
hitPKmax
if
pi
+
1
<
p
.
c
{
// k=+∞ @p.c
t
.
hitK
max
.
set
(
p
.
x
[
pi
+
1
]
.
k
)
}
t
.
hitKmax
=
kmax
t
.
hitPi
=
pi
+
1
}
else
{
t
.
insert
(
q
,
i
,
k
,
v
)
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) {
i
-=
kx
+
1
t
.
hitKmin
.
set
(
p
.
x
[
pi
]
.
k
)
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
)
}
}
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