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
be48a068
Commit
be48a068
authored
Jun 24, 2013
by
Jan Mercl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor tweaks
parent
79a6095c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
all_test.go
all_test.go
+7
-7
btree.go
btree.go
+7
-7
No files found.
all_test.go
View file @
be48a068
...
...
@@ -512,7 +512,7 @@ func BenchmarkDelRnd(b *testing.B) {
}
func
TestDelete2
(
t
*
testing
.
T
)
{
const
N
=
10
0000
const
N
=
8
0000
for
_
,
x
:=
range
[]
int
{
0
,
-
1
,
0x55555555
,
0xaaaaaaaa
,
314159265
}
{
r
:=
TreeNew
(
cmp
)
set
:=
r
.
Set
...
...
@@ -563,7 +563,7 @@ func TestEnumeratorNext(t *testing.T) {
r
.
Set
(
30
,
300
)
for
verChange
:=
0
;
verChange
<
16
;
verChange
++
{
t
.
Logf
(
"Seek %d"
,
test
.
k
)
//
t.Logf("Seek %d", test.k)
en
,
hit
:=
r
.
Seek
(
test
.
k
)
if
g
,
e
:=
hit
,
test
.
hit
;
g
!=
e
{
...
...
@@ -573,7 +573,7 @@ func TestEnumeratorNext(t *testing.T) {
j
:=
0
for
{
if
verChange
&
(
1
<<
uint
(
j
))
!=
0
{
t
.
Log
(
"version change"
)
//
t.Log("version change")
r
.
Set
(
20
,
200
)
}
...
...
@@ -586,7 +586,7 @@ func TestEnumeratorNext(t *testing.T) {
break
}
t
.
Logf
(
"Next -> %v: %v"
,
k
,
v
)
//
t.Logf("Next -> %v: %v", k, v)
if
j
>=
len
(
up
)
{
t
.
Fatal
(
i
,
j
,
verChange
)
}
...
...
@@ -636,7 +636,7 @@ func TestEnumeratorPrev(t *testing.T) {
r
.
Set
(
30
,
300
)
for
verChange
:=
0
;
verChange
<
16
;
verChange
++
{
t
.
Logf
(
"Seek %d"
,
test
.
k
)
//
t.Logf("Seek %d", test.k)
en
,
hit
:=
r
.
Seek
(
test
.
k
)
if
g
,
e
:=
hit
,
test
.
hit
;
g
!=
e
{
...
...
@@ -646,7 +646,7 @@ func TestEnumeratorPrev(t *testing.T) {
j
:=
0
for
{
if
verChange
&
(
1
<<
uint
(
j
))
!=
0
{
t
.
Log
(
"version change"
)
//
t.Log("version change")
r
.
Set
(
20
,
200
)
}
...
...
@@ -659,7 +659,7 @@ func TestEnumeratorPrev(t *testing.T) {
break
}
t
.
Logf
(
"Prev -> %v: %v"
,
k
,
v
)
//
t.Logf("Prev -> %v: %v", k, v)
if
j
>=
len
(
dn
)
{
t
.
Fatal
(
i
,
j
,
verChange
)
}
...
...
btree.go
View file @
be48a068
...
...
@@ -13,10 +13,10 @@
// $ make generic
//
// Performing it will write to stdout a version of the btree.go file where
// every key type occurrence is replaced by the word
KEY and every value type
//
occurrence is replaced by the word VALUE. In both cases as seen here, ie.
//
all upper case letters. Then you have to replace the strings {KEY,VALUE}
//
with your
desired type(s), using any technique you're comfortable with.
// every key type occurrence is replaced by the word
'key' (written in all
//
CAPS) and every value type occurrence is replaced by the word 'value'
//
(written in all CAPS). Then you have to replace theses strings with your
// desired type(s), using any technique you're comfortable with.
package
b
import
(
...
...
@@ -26,8 +26,8 @@ import (
//TODO check vs orig initialize/finalize
const
(
kx
=
128
//TODO benchmark tune this number if
key type is not interface{}
kd
=
64
//TODO benchmark tune this number if
value type is not interface{}
kx
=
128
//TODO benchmark tune this number if
using custom key/value type(s).
kd
=
64
//TODO benchmark tune this number if
using custom key/value type(s).
)
type
(
...
...
@@ -473,7 +473,6 @@ func (t *Tree) SeekLast() (e *Enumerator, err error) {
// Set sets the value associated with k.
func
(
t
*
Tree
)
Set
(
k
interface
{}
/*K*/
,
v
interface
{}
/*V*/
)
{
t
.
ver
++
pi
:=
-
1
var
p
*
x
q
:=
t
.
r
...
...
@@ -505,6 +504,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
default
:
t
.
overflow
(
p
,
x
,
pi
,
i
,
k
,
v
)
}
t
.
ver
++
return
}
}
...
...
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