trie: Index | Files

package trie

import ""

Package trie implements a thread-safe trie, also known as digital tree or prefix tree. It can be used as a drop-in replacement for usual Go maps with string keys.


Package Files


type Trie Uses

type Trie struct {
    // contains filtered or unexported fields

A Trie is an ordered tree data structure.

func NewTrie Uses

func NewTrie() *Trie

NewTrie creates a new empty trie.

func (*Trie) Delete Uses

func (trie *Trie) Delete(key string) bool

Delete removes the data stored at the given key and returns true on success and false if the key wasn't previously set.

func (*Trie) HasPrefix Uses

func (trie *Trie) HasPrefix(prefix string) map[string]interface{}

HasPrefix returns the map of all the keys and their corresponding data for the given key prefix.

func (*Trie) Insert Uses

func (trie *Trie) Insert(key string, data interface{})

Insert adds or replaces the data stored at the given key.

func (*Trie) Len Uses

func (trie *Trie) Len() int

Len returns the total number of keys stored in the trie.

func (*Trie) NodeNum Uses

func (trie *Trie) NodeNum() int

NodeNum returns the total number of internal nodes in the trie, which can be useful for debugging.

func (*Trie) Search Uses

func (trie *Trie) Search(key string) interface{}

Search returns the data stored at the given key.

Package trie imports 1 packages (graph). Updated 2020-01-09. Refresh now. Tools for package owners.