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
4959c522
Commit
4959c522
authored
Apr 13, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a727ee64
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
btree.go
btree.go
+7
-10
No files found.
btree.go
View file @
4959c522
...
...
@@ -349,6 +349,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
t
.
extract
(
dd
,
i
)
if
p
!=
nil
{
// NOTE underflow corrects hit D,Di, P,Pi, Kmin, Kmax as needed
t
.
underflow
(
p
,
dd
,
pi
)
}
else
if
t
.
c
==
0
{
t
.
Clear
()
...
...
@@ -421,7 +422,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
if
x
.
c
<
kd
{
if
q
!=
t
.
r
{
// NOTE underflow
will correct hit Kmin, Kmax, P and Pi
as needed
// NOTE underflow
corrects hit D,Di, P,Pi, Kmin, Kmax
as needed
t
.
underflow
(
p
,
x
,
pi
)
}
else
if
t
.
c
==
0
{
t
.
Clear
()
...
...
@@ -980,28 +981,25 @@ func (t *Tree) underflow(p *x, q *d, pi int) {
l
,
r
:=
p
.
siblings
(
pi
)
if
l
!=
nil
&&
l
.
c
+
q
.
c
>=
2
*
kd
{
//dbg("\tunderflow -> mv-from-l")
l
.
mvR
(
q
,
1
)
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
t
.
hitDi
+=
1
return
}
if
r
!=
nil
&&
q
.
c
+
r
.
c
>=
2
*
kd
{
//dbg("\tunderflow -> mv-from-r")
q
.
mvL
(
r
,
1
)
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
// hitDi stays the same
r
.
d
[
r
.
c
]
=
zde
// GC
return
}
if
l
!=
nil
{
//dbg("\tunderflow -> cat l <- q")
t
.
hitD
=
l
t
.
hitDi
+=
l
.
c
pi
--
...
...
@@ -1012,7 +1010,7 @@ func (t *Tree) underflow(p *x, q *d, pi int) {
t
.
hitP
=
nil
t
.
hitPi
=
-
1
}
else
{
if
pi
>
0
{
if
pi
>
0
{
// k=-∞ @-1
t
.
hitKmin
.
set
(
p
.
x
[
pi
-
1
]
.
k
)
}
t
.
hitPi
=
pi
...
...
@@ -1020,7 +1018,6 @@ func (t *Tree) underflow(p *x, q *d, pi int) {
return
}
//dbg("\tunderflow -> cat q <- r")
t
.
cat
(
p
,
q
,
r
,
pi
)
// hitD/hitDi stays unchanged
t
.
hitKmax
=
t
.
hitPKmax
...
...
@@ -1029,10 +1026,10 @@ func (t *Tree) underflow(p *x, q *d, pi int) {
t
.
hitP
=
nil
t
.
hitPi
=
-
1
}
else
{
if
pi
<
p
.
c
{
//
means < ∞
if
pi
<
p
.
c
{
//
k=+∞ @p.c
t
.
hitKmax
.
set
(
p
.
x
[
pi
]
.
k
)
}
t
.
hitPi
=
pi
// XXX? (+ already pre-set this way ?)
//t.hitPi = pi already pre-set this way
}
}
...
...
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