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
c4adf3a5
Commit
c4adf3a5
authored
Jan 29, 2015
by
Jan Mercl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve code style.
parent
930b360e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
20 deletions
+34
-20
Makefile
Makefile
+8
-3
btree.go
btree.go
+26
-17
No files found.
Makefile
View file @
c4adf3a5
...
...
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
.PHONY
:
all todo clean cover generic mem nuke
.PHONY
:
all todo clean cover generic mem nuke
cpu
testbin
=
b.test
...
...
@@ -14,17 +14,22 @@ all: editor
make todo
editor
:
go
fmt
go
fmt
-l
-s
-w
.
go
test
-i
go
test
clean
:
@
go clean
rm
-f
*
~
rm
-f
*
~
*
.out
$(testbin)
cover
:
t
=
$(
shell
tempfile
)
;
go
test
-coverprofile
$$
t
&&
go tool cover
-html
$$
t
&&
unlink
$$
t
cpu
:
go
test
-c
./
$(testbin)
-test
.cpuprofile cpu.out
go tool pprof
--lines
$(testbin)
cpu.out
generic
:
@
# writes to stdout a version where the type of key is KEY and the type
@
# of value is VALUE.
...
...
btree.go
View file @
c4adf3a5
...
...
@@ -285,7 +285,9 @@ func (t *Tree) cat(p *x, q, r *d, pi int) {
if
p
.
c
>
1
{
p
.
extract
(
pi
)
p
.
x
[
pi
]
.
ch
=
q
}
else
{
return
}
switch
x
:=
t
.
r
.
(
type
)
{
case
*
x
:
*
x
=
zx
...
...
@@ -295,7 +297,6 @@ func (t *Tree) cat(p *x, q, r *d, pi int) {
btDPool
.
Put
(
x
)
}
t
.
r
=
q
}
}
func
(
t
*
Tree
)
catX
(
p
,
q
,
r
*
x
,
pi
int
)
{
...
...
@@ -513,10 +514,11 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
q
.
mvR
(
r
,
1
)
t
.
insert
(
q
,
i
,
k
,
v
)
p
.
x
[
pi
]
.
k
=
r
.
d
[
0
]
.
k
}
else
{
return
}
t
.
insert
(
r
,
0
,
k
,
v
)
p
.
x
[
pi
]
.
k
=
k
}
return
}
...
...
@@ -790,15 +792,22 @@ func (t *Tree) underflow(p *x, q *d, pi int) {
if
l
!=
nil
&&
l
.
c
+
q
.
c
>=
2
*
kd
{
l
.
mvR
(
q
,
1
)
p
.
x
[
pi
-
1
]
.
k
=
q
.
d
[
0
]
.
k
}
else
if
r
!=
nil
&&
q
.
c
+
r
.
c
>=
2
*
kd
{
return
}
if
r
!=
nil
&&
q
.
c
+
r
.
c
>=
2
*
kd
{
q
.
mvL
(
r
,
1
)
p
.
x
[
pi
]
.
k
=
r
.
d
[
0
]
.
k
r
.
d
[
r
.
c
]
=
zde
// GC
}
else
if
l
!=
nil
{
return
}
if
l
!=
nil
{
t
.
cat
(
p
,
l
,
q
,
pi
-
1
)
}
else
{
t
.
cat
(
p
,
q
,
r
,
pi
)
return
}
t
.
cat
(
p
,
q
,
r
,
pi
)
}
func
(
t
*
Tree
)
underflowX
(
p
*
x
,
q
*
x
,
pi
int
,
i
int
)
(
*
x
,
int
)
{
...
...
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