trie

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: MIT Imports: 2 Imported by: 0

README

Immutable Trie Structure for Go

Go Report Card Build Status Test Coverage Maintainability GitHub

Current Status

Still a work in progress. Use at your own risk.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction[Key key.Keyable, Value any] interface {
	Select[Key, Value]
	Ascending() Select[Key, Value]
	Descending() Select[Key, Value]
}

type Filter

type Filter[Key key.Keyable, Value any] func(Key, Value) bool

type ForEach

type ForEach[Key key.Keyable, Value any] func(Key, Value)

type Iterator

type Iterator[Key key.Keyable, Value any] interface {
	Next() (Pair[Key, Value], Query[Key, Value], bool)
}

type Pair

type Pair[Key key.Keyable, Value any] interface {
	Key() Key
	Value() Value
	// contains filtered or unexported methods
}

Pair stores Key/Value pairs

type Query

type Query[Key key.Keyable, Value any] interface {
	Iterator[Key, Value]
	ForEach(ForEach[Key, Value])
	Where(Filter[Key, Value]) Query[Key, Value]
	While(Filter[Key, Value]) Query[Key, Value]
}

type Read

type Read[Key key.Keyable, Value any] interface {
	Get(Key) (Value, bool)
	Count() int
	IsEmpty() bool
	Select() Direction[Key, Value]
}

type Select

type Select[Key key.Keyable, Value any] interface {
	All() Query[Key, Value]
	From(Key) Query[Key, Value]
}

type Split

type Split[Key key.Keyable, Value any] interface {
	First() Pair[Key, Value]
	Rest() Trie[Key, Value]
	Split() (Pair[Key, Value], Trie[Key, Value], bool)
}

type Trie

type Trie[Key key.Keyable, Value any] interface {
	Read[Key, Value]
	Split[Key, Value]
	Write[Key, Value]
	// contains filtered or unexported methods
}

Trie maps a set of Keys to another set of Values

func From

func From[Value any](in map[string]Value) Trie[string, Value]

From builds a Trie from a map with string keys

func New

func New[Key key.Keyable, Value any]() Trie[Key, Value]

New returns a new empty Trie instance

type Write

type Write[Key key.Keyable, Value any] interface {
	Put(Key, Value) Trie[Key, Value]
	Remove(Key) (Value, Trie[Key, Value], bool)
	RemovePrefix(Key) (Trie[Key, Value], bool)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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