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
22a81b26
Commit
22a81b26
authored
Apr 13, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e13ff140
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
18 deletions
+11
-18
btree.go
btree.go
+11
-18
No files found.
btree.go
View file @
22a81b26
...
...
@@ -322,6 +322,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
switch
{
case
!
ok
:
// tried to delete last or element past max k in hitD
// see also "extract rule" below
if
i
>=
dd
.
c
{
i
--
}
...
...
@@ -330,6 +331,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
case
dd
.
c
>
kd
:
t
.
extract
(
dd
,
i
)
// extract rule for t.hitDi
if
t
.
hitDi
>=
dd
.
c
{
t
.
hitDi
--
}
...
...
@@ -346,13 +348,13 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
t
.
extract
(
dd
,
i
)
// XXX recheck
if
p
!=
nil
{
t
.
underflow
(
p
,
dd
,
pi
)
}
else
if
t
.
c
==
0
{
t
.
Clear
()
}
// extract rule for t.hitDi
if
t
.
hitD
!=
nil
&&
t
.
hitDi
>=
t
.
hitD
.
c
{
t
.
hitDi
--
}
...
...
@@ -381,6 +383,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
}
if
x
.
c
<
kx
&&
q
!=
t
.
r
{
// NOTE underflowX will correct ... XXX do we need this comment ?
x
,
i
=
t
.
underflowX
(
p
,
x
,
pi
,
i
)
}
...
...
@@ -391,11 +394,11 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
pi
=
i
q
=
x
.
x
[
pi
]
.
ch
if
pi
>
0
{
if
pi
>
0
{
// k=-∞ @ pi=-1
t
.
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
}
if
pi
<
p
.
c
{
// k=∞ @ pi=p.c
if
pi
<
p
.
c
{
// k=
+
∞ @ pi=p.c
t
.
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
}
...
...
@@ -418,13 +421,14 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
if
x
.
c
<
kd
{
if
q
!=
t
.
r
{
// NOTE
ov
erflow will correct hit Kmin, Kmax, P and Pi as needed
// NOTE
und
erflow will correct hit Kmin, Kmax, P and Pi as needed
t
.
underflow
(
p
,
x
,
pi
)
}
else
if
t
.
c
==
0
{
t
.
Clear
()
}
}
// extract rule for t.hitDi
if
t
.
hitD
!=
nil
&&
t
.
hitDi
>=
t
.
hitD
.
c
{
t
.
hitDi
--
}
...
...
@@ -761,11 +765,10 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
}
if
x
.
c
>
2
*
kx
{
//
dbg("splitX")
//
NOTE splitX will correct ... XXX do we need this comment ?
x
,
i
=
t
.
splitX
(
p
,
x
,
pi
,
i
)
}
//hitPKmax = hitKmax
t
.
hitPKmin
=
t
.
hitKmin
t
.
hitPKmax
=
t
.
hitKmax
...
...
@@ -773,16 +776,12 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
pi
=
i
q
=
p
.
x
[
pi
]
.
ch
if
pi
>
0
{
//hitKmin.set(p.x[pi-1].k)
if
pi
>
0
{
// k=-∞ @ pi=-1
t
.
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
//dbg("hitKmin: %v", hitKmin)
}
if
pi
<
p
.
c
{
// == p.c means ∞
//hitKmax.set(p.x[pi].k)
if
pi
<
p
.
c
{
// k=+∞ @ pi=p.c
t
.
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
//dbg("hitKmax: %v", hitKmax)
}
...
...
@@ -790,22 +789,16 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
// data page found - perform the update
t
.
hitP
=
p
t
.
hitPi
=
pi
//t.hitKmin = hitKmin
//t.hitKmax = hitKmax
//t.hitPKmax = hitPKmax
switch
{
case
ok
:
//dbg("ok")
x
.
d
[
i
]
.
v
=
v
t
.
hitD
,
t
.
hitDi
=
x
,
i
case
x
.
c
<
2
*
kd
:
//dbg("insert")
t
.
insert
(
x
,
i
,
k
,
v
)
default
:
//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