iterator

package
v0.0.0-...-cd2696f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2013 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package iterator provides interface and implementation to traverse over contents of a database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyIterator

type EmptyIterator struct {
	Err error
}

func (*EmptyIterator) Error

func (i *EmptyIterator) Error() error

func (*EmptyIterator) First

func (*EmptyIterator) First() bool

func (*EmptyIterator) Key

func (*EmptyIterator) Key() []byte

func (*EmptyIterator) Last

func (*EmptyIterator) Last() bool

func (*EmptyIterator) Next

func (*EmptyIterator) Next() bool

func (*EmptyIterator) Prev

func (*EmptyIterator) Prev() bool

func (*EmptyIterator) Seek

func (*EmptyIterator) Seek(key []byte) bool

func (*EmptyIterator) Valid

func (*EmptyIterator) Valid() bool

func (*EmptyIterator) Value

func (*EmptyIterator) Value() []byte

type IndexedIterator

type IndexedIterator struct {
	// contains filtered or unexported fields
}

IndexedIterator represent an indexed interator. IndexedIterator can be used to access an indexed data, which the index is a pointer to actual data.

func NewIndexedIterator

func NewIndexedIterator(index IteratorIndexer) *IndexedIterator

NewIndexedIterator create new initialized indexed iterator.

func (*IndexedIterator) Error

func (i *IndexedIterator) Error() error

func (*IndexedIterator) First

func (i *IndexedIterator) First() bool

func (*IndexedIterator) Key

func (i *IndexedIterator) Key() []byte

func (*IndexedIterator) Last

func (i *IndexedIterator) Last() bool

func (*IndexedIterator) Next

func (i *IndexedIterator) Next() bool

func (*IndexedIterator) Prev

func (i *IndexedIterator) Prev() bool

func (*IndexedIterator) Seek

func (i *IndexedIterator) Seek(key []byte) bool

func (*IndexedIterator) Valid

func (i *IndexedIterator) Valid() bool

func (*IndexedIterator) Value

func (i *IndexedIterator) Value() []byte

type Iterator

type Iterator interface {
	IteratorSeeker

	// Return the key for the current entry.  The underlying storage for
	// the returned slice is valid only until the next modification of
	// the iterator.
	// REQUIRES: Valid()
	Key() []byte

	// Return the value for the current entry.  The underlying storage for
	// the returned slice is valid only until the next modification of
	// the iterator.
	// REQUIRES: !AtEnd() && !AtStart()
	Value() []byte
}

type IteratorIndexer

type IteratorIndexer interface {
	IteratorSeeker

	// Return iterator for current entry.
	Get() (Iterator, error)
}

IteratorIndexer is the interface that group IteratorSeeker and basic Get method. An index of indexed iterator need to implement this interface.

type IteratorSeeker

type IteratorSeeker interface {
	// An iterator is either positioned at a key/value pair, or
	// not valid.  This method returns true if the iterator is valid.
	Valid() bool

	// Position at the first key in the source.  The iterator is Valid()
	// after this call if the source is not empty.
	First() bool

	// Position at the last key in the source.  The iterator is
	// Valid() after this call if the source is not empty.
	Last() bool

	// Position at the first key in the source that at or past given 'key'
	// The iterator is Valid() after this call if the source contains
	// an entry that comes at or past given 'key'.
	Seek(key []byte) bool

	// Moves to the next entry in the source.  After this call, Valid() is
	// true if the iterator was not positioned at the last entry in the source.
	// REQUIRES: Valid()
	Next() bool

	// Moves to the previous entry in the source.  After this call, Valid() is
	// true if the iterator was not positioned at the first entry in source.
	// REQUIRES: Valid()
	Prev() bool

	// If an error has occurred, return it.  Else return nil.
	Error() error
}

type MergedIterator

type MergedIterator struct {
	// contains filtered or unexported fields
}

MergedIterator represent a merged iterators. MergedIterator can be used to merge multiple iterators into one.

func NewMergedIterator

func NewMergedIterator(iters []Iterator, cmp comparer.Comparer) *MergedIterator

NewMergedIterator create new initialized merged iterators.

func (*MergedIterator) Error

func (i *MergedIterator) Error() error

func (*MergedIterator) First

func (i *MergedIterator) First() bool

func (*MergedIterator) Key

func (i *MergedIterator) Key() []byte

func (*MergedIterator) Last

func (i *MergedIterator) Last() bool

func (*MergedIterator) Next

func (i *MergedIterator) Next() bool

func (*MergedIterator) Prev

func (i *MergedIterator) Prev() bool

func (*MergedIterator) Seek

func (i *MergedIterator) Seek(key []byte) bool

func (*MergedIterator) Valid

func (i *MergedIterator) Valid() bool

func (*MergedIterator) Value

func (i *MergedIterator) Value() []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL