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
c685a6c5
Commit
c685a6c5
authored
Jun 24, 2013
by
jnml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add additional Seek methods
parent
d1f6c902
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
btree.go
btree.go
+22
-0
No files found.
btree.go
View file @
c685a6c5
...
...
@@ -449,6 +449,28 @@ func (t *Tree) Seek(k interface{} /*K*/) (e *Enumerator, ok bool) {
}
}
// SeekFirst returns an enumerator positioned on the first KV pair in the tree,
// if any. For an empty tree, err == io.EOF is returned and e will be nil.
func
(
t
*
Tree
)
SeekFirst
()
(
e
*
Enumerator
,
err
error
)
{
q
:=
t
.
first
if
q
==
nil
{
return
nil
,
io
.
EOF
}
return
&
Enumerator
{
nil
,
true
,
0
,
q
.
d
[
0
]
.
k
,
q
,
t
,
t
.
ver
},
nil
}
// SeekLast returns an enumerator positioned on the last KV pair in the tree,
// if any. For an empty tree, err == io.EOF is returned and e will be nil.
func
(
t
*
Tree
)
SeekLast
()
(
e
*
Enumerator
,
err
error
)
{
q
:=
t
.
last
if
q
==
nil
{
return
nil
,
io
.
EOF
}
return
&
Enumerator
{
nil
,
true
,
q
.
c
-
1
,
q
.
d
[
q
.
c
-
1
]
.
k
,
q
,
t
,
t
.
ver
},
nil
}
// Set sets the value associated with k.
func
(
t
*
Tree
)
Set
(
k
interface
{}
/*K*/
,
v
interface
{}
/*V*/
)
{
t
.
ver
++
...
...
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