trie

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: MIT Imports: 3 Imported by: 6

README

trie

Build Status Go Report Card GoDoc GitHub license gocover.io

Trie is a Trie Zipper Tree implementation in Golang.

ok  	github.com/wzshiming/trie	0.580s	coverage: 99.3% of statements

BenchmarkTrie_Get1-4   	58407358	      20.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkTrie_Put1-4   	11237943	       109 ns/op	       0 B/op	       0 allocs/op

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Trie

type Trie[T any] struct {
	// contains filtered or unexported fields
}

Trie is a trie tree implementation.

func NewTrie

func NewTrie[T any]() *Trie[T]

NewTrie returns a new Trie.

func (*Trie[T]) Depth added in v0.1.0

func (t *Trie[T]) Depth() int

Depth returns the depth of the trie.

func (*Trie) Get

func (m *Trie) Get(key []byte) (val T, current *mapping[T], finish bool)

Get returns the val in the trie for a key.

func (*Trie[T]) Keys

func (t *Trie[T]) Keys() [][]byte

Keys returns all key of Trie.

func (*Trie[T]) Mapping

func (t *Trie[T]) Mapping() (m *mapping[T])

Mapping gets the mapping for get only.

func (*Trie[T]) Put

func (t *Trie[T]) Put(key []byte, val T) (finish bool)

Put sets the val in the trie for a key.

func (*Trie[T]) Size added in v0.1.0

func (t *Trie[T]) Size() int

Size returns the size of the trie.

func (*Trie[T]) String

func (t *Trie[T]) String() string

String returns format trie in a friendly.

func (*Trie[T]) Walk

func (t *Trie[T]) Walk(f func(k []byte, v T))

Walk calls f sequentially for each key and value present in the trie.

Jump to

Keyboard shortcuts

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