trie

package
v3.73.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 0 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 struct {
	// contains filtered or unexported fields
}

Trie is a trie data structure that supports insertion and lookup of strings and prefixes of inserted strings.

func New

func New() *Trie

New returns a new Trie.

func (*Trie) Contents

func (t *Trie) Contents() []string

Contents returns all the strings that have been inserted into the Trie. The worst case time complexity is O(m) where m is the sum of the lengths of all strings that have been inserted.

func (*Trie) Exists

func (t *Trie) Exists(word string) bool

Exists tests if the string `word` has been inserted into the Trie. It takes O(r) time where r is the length of `word`.

func (*Trie) Insert

func (t *Trie) Insert(word string)

Insert inserts the string `word` into the Trie. It takes O(r) time where r is the length of `word`.

func (*Trie) PrefixExists

func (t *Trie) PrefixExists(word string) bool

PrefixExists tests if the any string with the prefix `word` has been inserted into the Trie. It takes O(r) time where r is the length of `word`.

func (*Trie) Size

func (t *Trie) Size() int

Jump to

Keyboard shortcuts

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