memkv

package
Version: v0.0.0-...-7f9930a Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2015 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Enumerator

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

Enumerator is the iterator for btree

func (*Enumerator) Next

func (e *Enumerator) Next() (k []interface{}, v []interface{}, err error)

Next returns the currently enumerated item, if it exists and moves to the next item in the key collation order. If there is no item to return, err == io.EOF is returned.

func (*Enumerator) Prev

func (e *Enumerator) Prev() (k []interface{}, v []interface{}, err error)

Prev returns the currently enumerated item, if it exists and moves to the previous item in the key collation order. If there is no item to return, err == io.EOF is returned.

type Temp

type Temp interface {
	Drop() (err error)
	Get(k []interface{}) (v []interface{}, err error)
	SeekFirst() (e btreeIterator, err error)
	Set(k, v []interface{}) (err error)
}

Temp is the interface of a memory kv storage

func CreateTemp

func CreateTemp(asc bool) (_ Temp, err error)

CreateTemp returns a new empty memory kv

type Tree

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

Tree is a B+tree.

func NewTree

func NewTree(cmp cmp) *Tree

NewTree returns a newly created, empty tree. The compare function is used for key collation.

func (*Tree) Clear

func (t *Tree) Clear()

Clear removes all K/V pairs from the tree.

func (*Tree) Delete

func (t *Tree) Delete(k []interface{}) (ok bool)

Delete removes the k's KV pair, if it exists, in which case Delete returns true.

func (*Tree) First

func (t *Tree) First() (k []interface{}, v []interface{})

First returns the first item of the tree in the key collating order, or (nil, nil) if the tree is empty.

func (*Tree) Get

func (t *Tree) Get(k []interface{}) (v []interface{}, ok bool)

Get returns the value associated with k and true if it exists. Otherwise Get returns (nil, false).

func (*Tree) Last

func (t *Tree) Last() (k []interface{}, v []interface{})

Last returns the last item of the tree in the key collating order, or (nil, nil) if the tree is empty.

func (*Tree) Len

func (t *Tree) Len() int

Len returns the number of items in the tree.

func (*Tree) Seek

func (t *Tree) Seek(k []interface{}) (e *Enumerator, ok bool)

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.

func (*Tree) SeekFirst

func (t *Tree) SeekFirst() (e *Enumerator, err error)

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 (*Tree) SeekLast

func (t *Tree) SeekLast() (e *Enumerator, err error)

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 (*Tree) Set

func (t *Tree) Set(k []interface{}, v []interface{})

Set sets the value associated with k.

Source Files

Jump to

Keyboard shortcuts

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