lexicon

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2013 License: MIT Imports: 3 Imported by: 0

README

lexicon Build Status

A lexicographically ordered map for Go.

A lexicon is a synonym for dictionary.

It's a combination of a hashmap and an ordered list.

I've tried to make it as generic as possible, but since we need to have some way of knowing how to order elements, keys must implement orderedlist.Comparable.

type Comparable interface {
	Compare(c Comparable) int
}

Features

  • Fast key-value existence checks and retrieval
  • Range reads

API Documentation

The GoDoc generated documentation is here.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotPresent = errors.New("lexicon: key not present")

Functions

This section is empty.

Types

type KeyValue added in v0.3.0

type KeyValue struct {
	Key   orderedlist.Comparable
	Value interface{}
}

type Lexicon

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

Lexicon is an ordered key-value store.

func New

func New() *Lexicon

New returns an initialized lexicon.

func (*Lexicon) ClearRange added in v0.3.0

func (lex *Lexicon) ClearRange(start orderedlist.Comparable, end orderedlist.Comparable)

ClearRange removes a range of key-value pairs. The range is from [start, end).

func (*Lexicon) Get

func (lex *Lexicon) Get(key orderedlist.Comparable) (interface{}, error)

Get returns a value at the given key.

func (*Lexicon) GetRange

func (lex *Lexicon) GetRange(start orderedlist.Comparable, end orderedlist.Comparable) (kv []KeyValue)

GetRange returns a slice of KeyValue structs. The range is from [start, end).

func (*Lexicon) Remove

func (lex *Lexicon) Remove(key orderedlist.Comparable)

Remove deletes a key-value pair.

func (*Lexicon) Set

func (lex *Lexicon) Set(key orderedlist.Comparable, value interface{})

Set sets a key to a value.

func (*Lexicon) SetMany added in v0.3.0

func (lex *Lexicon) SetMany(kv map[orderedlist.Comparable]interface{})

SetMany sets multiple key-value pairs.

Jump to

Keyboard shortcuts

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