trie

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package trie implements a in-memory trie tree. Reference: Trie - Wikipedia, the free encyclopedia

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 the trie tree.

func New

func New() *Trie

New creates a new Trie.

func (*Trie) Clear

func (tr *Trie) Clear()

Clear the trie.

func (*Trie) Get

func (tr *Trie) Get(key string) interface{}

Get an item from the trie. Returns nil if not found.

func (*Trie) Has

func (tr *Trie) Has(key string) bool

Has checks if an item is in trie. Returns true if the given key is in the trie.

func (*Trie) Len

func (tr *Trie) Len() int

Len returns the trie length.

func (*Trie) Map

func (tr *Trie) Map() map[string]interface{}

Map returns the full trie as a map.

func (*Trie) Match

func (tr *Trie) Match(pattern string) map[string]interface{}

Match trie items by a wildcard like pattern, the pattern is not a traditional wildcard, only "*" is supported, a sinle "*" represents a single word. Returns an empty map if the given pattern matches no items.

func (*Trie) Matched added in v0.2.1

func (tr *Trie) Matched(s string) map[string]interface{}

Matched uses the trie items as the wildcard like patterns, filters out the items matches the given string. Returns an empty map if the given strings matches no patterns.

func (*Trie) NumMatch added in v0.2.1

func (tr *Trie) NumMatch(pattern string) int

NumMatch returns the number of items matching given pattern. Better than len(tr.Match(pattern)).

func (*Trie) Pop

func (tr *Trie) Pop(key string) interface{}

Pop an item from the trie. Returns nil if the given key is not in the trie.

func (*Trie) Put

func (tr *Trie) Put(key string, value interface{})

Put an item to the trie. Replace if the key conflicts.

Jump to

Keyboard shortcuts

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