-
Notifications
You must be signed in to change notification settings - Fork 4
/
iterator.go
56 lines (42 loc) · 1.75 KB
/
iterator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package leveldb
import (
"io"
"github.com/kezhuw/leveldb/internal/iterator"
)
// Iterator defines methods to iterate through a set of data. The initial
// status of an newly created iterator is invalid. Client must call one of
// the seek methods before using. All iterators returned from this package
// are not designed for concurrent usage.
type Iterator interface {
// Next moves to next entry. It returns whether such entry exists.
// If it is the first seek method called, it behaves as First().
Next() bool
// Prev moves to previous entry. It returns whether such entry exists.
// If it is the first seek method called, it behaves as Last().
Prev() bool
// First moves to the first entry. It returns whether such entry exists.
First() bool
// Last moves to the last entry. It returns whether such entry exists.
Last() bool
// Seek moves the iterator to the first key that equal to or greater than
// key. It returns whether such entry exists.
Seek(key []byte) bool
// Valid returns whether the iterator is point to a valid entry.
Valid() bool
// Key returns the key of current entry. The behaviour is undefined if
// current status of iterator is invalid.
Key() []byte
// Value returns the value of current entry. The behaviour is undefined
// if current status of iterator is invalid.
Value() []byte
// Err returns error we encounters so far. Seek methods, First, Last and Seek may
// clear this error.
Err() error
// Closes releases any resources hold by this iterator, and returns
// any error it encounters so far. The behaviour is undefined if you
// call any methods after this iterator has been closed.
Close() error
}
var _ io.Closer = (Iterator)(nil)
var _ Iterator = (iterator.Iterator)(nil)
var _ iterator.Iterator = (Iterator)(nil)