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
b96e30f1
Commit
b96e30f1
authored
Sep 21, 2015
by
Jan Mercl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add seek test.
parent
e2e747ce
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
all_test.go
all_test.go
+32
-0
btree.go
btree.go
+3
-3
No files found.
all_test.go
View file @
b96e30f1
...
...
@@ -1298,3 +1298,35 @@ func TestPut(t *testing.T) {
}
}
}
func
TestSeek
(
t
*
testing
.
T
)
{
const
N
=
1
<<
13
tr
:=
TreeNew
(
cmp
)
for
i
:=
0
;
i
<
N
;
i
++
{
k
:=
2
*
i
+
1
tr
.
Set
(
k
,
nil
)
}
for
i
:=
0
;
i
<
N
;
i
++
{
k
:=
2
*
i
e
,
ok
:=
tr
.
Seek
(
k
)
if
ok
{
t
.
Fatal
(
k
)
}
for
j
:=
i
;
j
<
N
;
j
++
{
k2
,
_
,
err
:=
e
.
Next
()
if
err
!=
nil
{
t
.
Fatal
(
k
,
err
)
}
if
g
,
e
:=
k2
,
2
*
j
+
1
;
g
!=
e
{
t
.
Fatal
(
j
,
g
,
e
)
}
}
_
,
_
,
err
:=
e
.
Next
()
if
err
!=
io
.
EOF
{
t
.
Fatalf
(
"expected io.EOF, got %v"
,
err
)
}
}
}
btree.go
View file @
b96e30f1
...
...
@@ -473,9 +473,9 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
t
.
split
(
p
,
q
,
pi
,
i
,
k
,
v
)
}
// Seek returns an Enumerator positioned on a
an item such that k >= item's
//
key. ok reports if k == item.key The Enumerator's position is possibly
//
after the
last item in the tree.
// Seek returns an Enumerator positioned on a
n item such that k >= item's key.
//
ok reports if k == item.key The Enumerator's position is possibly after the
// last item in the tree.
func
(
t
*
Tree
)
Seek
(
k
interface
{}
/*K*/
)
(
e
*
Enumerator
,
ok
bool
)
{
q
:=
t
.
r
if
q
==
nil
{
...
...
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