You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.
A standard idiom for enumerators seems to have emerged [1],[2],
which makes for quite nice looking code. Perhaps consider
using that here.
Something like this perhaps?
type Enumerator struct {...}
// Next moves to the next element in the enumeration.
// It returns false when there are no more entries
// or if there's an error.
func (*Enumerator) Next() bool
// Prev moves to the previous element in the enumeration.
// It returns false when there are no more entries
// or if there's an error.
func (*Enumerator) Prev() bool
// Key returns the key at the current enumerator position.
func (*Enumerator) Key() []byte
// Value returns the value at the current enumerator position.
func (*Enumerator) Value() []byte
// Err returns any error encountered during the enumeration.
func (*Enumerator) Err() error
Example usage:
enum := db.SeekFirst()
for enum.Next() {
fmt.Printf("%s=%s\n", enum.Key(), enum.Value())
}
if err := enum.Err(); err != nil {
log.Fatal(err)
}
@rogpeppe Thanks for the suggestions. Could you please checkout branch issue25 (should have been named issue26, but I errored) and test and review the changes? I would like to know your opinions before publishing it on master. Thanks in advance.
A standard idiom for enumerators seems to have emerged [1],[2],
which makes for quite nice looking code. Perhaps consider
using that here.
Something like this perhaps?
Example usage:
[1] http://golang.org/pkg/bufio/#Scanner
[2] http://godoc.org/gopkg.in/mgo.v2#Iter
The text was updated successfully, but these errors were encountered: