trie

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Trie

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

func New

func New[V any]() *Trie[V]

func (*Trie[V]) Delete

func (t *Trie[V]) Delete(k string)

删除有两种方法, 这里先选择第1种,后面有时间再压测下第二种效率如何 1.记录rune和节点,删除这个节点。如果是子节点,再回溯删除 2.声明一个parent指针,不记录过程节点,直接p = n.parent; p != nil; p=p.parent 回溯删除

func (*Trie[V]) Get

func (t *Trie[V]) Get(k string) (v V)

func (*Trie[V]) GetWithBool

func (t *Trie[V]) GetWithBool(k string) (v V, found bool)

func (*Trie[V]) HasPrefix

func (t *Trie[V]) HasPrefix(k string) bool

func (*Trie[V]) Len

func (t *Trie[V]) Len() int

func (*Trie[V]) Set

func (t *Trie[V]) Set(k string, v V)

func (*Trie[V]) SetWithPrev

func (t *Trie[V]) SetWithPrev(k string, v V) (prev V, replaced bool)

Jump to

Keyboard shortcuts

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