listmap

package module
v0.0.0-...-f2d06fb Latest Latest
Warning

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

Go to latest
Published: May 18, 2016 License: MIT Imports: 6 Imported by: 4

README

listmap CircleCI GoDoc

listmap is a persistent (as in backed by a file system), ordered linked list implementation in Go.

License

MIT

Documentation

Overview

Package listmap implements an ordered doubly linked list map.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound       = errors.New("listmap: key not found")
	ErrKeyPresent        = errors.New("listmap: key already present")
	ErrFileTruncateError = errors.New("listmap: file truncate error")
	ErrUnknown           = errors.New("listmap: unknown error")
)

Functions

This section is empty.

Types

type Cursor

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

Cursor represents a cursor in the map.

func (*Cursor) Key

func (c *Cursor) Key() []byte

Key returns the key of the element at the current location of the cursor. The returned slice is a subslice of the memory-mapped file, so modifications may lead to corruption of the list.

func (*Cursor) Next

func (c *Cursor) Next() *Cursor

Next moves the cursor to the next element in the Listmap and returns a pointer to itself or nil if the end of the list is reached. This modifies the original cursor.

func (*Cursor) Prev

func (c *Cursor) Prev() *Cursor

Prev moves the cursor to the previous element in the Listmap and returns a pointer to itself or nil when moved behind the first element. This modifies the original cursor.

func (*Cursor) Value

func (c *Cursor) Value() []byte

Value returns the value of the element at the current location of the cursor. The returned slice is a subslice of the memory-mapped file, so modifications may lead to corruption of the list.

type Listmap

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

Listmap represents an ordered doubly linked list map.

func NewListmap

func NewListmap(file string) (*Listmap, error)

NewListmap returns a pointer to an initialized list backed by file or nil in the case of an error. file will be truncated.

func OpenListmap

func OpenListmap(file string) (*Listmap, error)

OpenListmap returns a pointer to an existing Listmap backed by file or nil in the case of an error.

func (*Listmap) Close

func (l *Listmap) Close()

Close closes an initialized Listmap.

func (*Listmap) Destroy

func (l *Listmap) Destroy()

Destroy closes an initialized Listmap and removes its associated file.

func (*Listmap) Get

func (l *Listmap) Get(key []byte) ([]byte, error)

Get returns the value in the Listmap associated with key.

func (*Listmap) NewCursor

func (l *Listmap) NewCursor() *Cursor

NewCursor returns a pointer to a cursor positioned at the first element of the Listmap.

func (*Listmap) Remove

func (l *Listmap) Remove(key []byte)

Remove marks a key as removed

func (*Listmap) Set

func (l *Listmap) Set(key, value []byte) error

Set writes a key-value pair to a Listmap. Records are kept in lexicographical order.

func (*Listmap) Size

func (l *Listmap) Size() int

Size returns the current file size of the Listmap. Note: this is the raw file size, not the amount of data stored in the Listmap.

Jump to

Keyboard shortcuts

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