basic

package
v0.0.0-...-ed519ab Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

inspire from - https://godoc.org/golang.org/x/text/internal/triegen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a fast thread-safe in memory cache optimized for big number of entries.

func New

func New(maxBytes int) *Cache

New returns new cache with the given maxBytes capacity in bytes. default size is 4m

func (*Cache) Del

func (c *Cache) Del(k []byte)

Del deletes value for the given k from the cache.

k contents may be modified after returning from Del.

func (*Cache) Get

func (c *Cache) Get(dst, k []byte) []byte

Get appends value by the key k to dst and returns the result. Get allocates new byte slice for the returned value if dst is nil. Get returns only values stored in c via Set. k contents may be modified after returning from Get.

func (*Cache) Has

func (c *Cache) Has(k []byte) bool

Has returns true if entry for the given key k exists in the cache.

func (*Cache) Reset

func (c *Cache) Reset()

Reset removes all the items from the cache.

func (*Cache) Set

func (c *Cache) Set(k, v []byte)

Set stores (k, v) in the cache.

type Node

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

Node trie tree node container carries value and children.

type Trie

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

Trie is a trie container.

func NewTrie

func NewTrie() *Trie

NewTrie create a new trie.

func (*Trie) Clear

func (t *Trie) Clear()

Clear set the entire tree to invalid status

func (*Trie) Insert

func (t *Trie) Insert(key string)

Insert insert a key.

func (*Trie) PrefixMatch

func (t *Trie) PrefixMatch(key string) []string

func (*Trie) Remove

func (t *Trie) Remove(key string)

Remove a key but not delete it really

func (*Trie) Reset

func (t *Trie) Reset()

func (*Trie) Root

func (t *Trie) Root() *Node

Root returns root node.

func (*Trie) Walk

func (t *Trie) Walk(node *Node) (ret []string)

Jump to

Keyboard shortcuts

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