trie

package
v0.6.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	PathVariablesSet map[string]*Node // in path /:a/b/c/:d , :a is a path variable node of level1 , :d is path variable node of level4
	PathVariableNode *Node            // in path /:a/b/c/:d , /b/c/:d is a child tree of pathVariable node :a ,and some special logic for match pathVariable it better not store in children.
	MatchAllNode     *Node            // /a/b/**  /** is a match all Node.
	// contains filtered or unexported fields
}

Node

func (*Node) Clear

func (node *Node) Clear() bool

func (*Node) Get

func (node *Node) Get(keys []string) (*Node, []string, bool, error)

Get node get returns: *Node this node in path, if not exists return nil []string key reversed array of pathVariable /:aa/:bb/:cc returns array of (cc,bb,aa) bool is ok error

func (*Node) GetBizInfo

func (node *Node) GetBizInfo() interface{}

GetBizInfo get info

func (*Node) IsEmpty

func (node *Node) IsEmpty() bool

IsEmpty return true if empty

func (*Node) Match

func (node *Node) Match(parts []string) (*Node, []string, bool)

type Trie

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

Trie

func NewTrie

func NewTrie() Trie

NewTrie

func NewTrieWithDefault

func NewTrieWithDefault(path string, defVal interface{}) Trie

NewTrieWithDefault

func (*Trie) Clear

func (trie *Trie) Clear() bool

func (Trie) Contains

func (trie Trie) Contains(withOutHost string) (bool, error)

Contains return if key exists in trie

func (Trie) Get

func (trie Trie) Get(withOutHost string) (*Node, []string, bool, error)

Get get values according key.pathVariable not supported.

func (*Trie) IsEmpty

func (trie *Trie) IsEmpty() bool

IsEmpty put key and values into trie as map.

func (Trie) Match

func (trie Trie) Match(withOutHost string) (*Node, []string, bool)

Match get values according url , pathVariable supported. returns: *Node this node in path, if not exists return nil []string reversed array of pathVariable value /valA/valB/valC matchs /:aa/:bb/:cc returns array of (valC,valB,valA) bool is ok error

func (*Trie) Put

func (trie *Trie) Put(withOutHost string, bizInfo interface{}) (bool, error)

Put put key and values into trie as map.

func (*Trie) PutOrUpdate

func (trie *Trie) PutOrUpdate(withOutHost string, bizInfo interface{}) (bool, error)

Put put key and values into trie as map.

func (Trie) Remove

func (trie Trie) Remove(withOutHost string) (*Node, error)

Remove remove key and value from trie. logic delete can't release memory, rebuild if necessary when lake of memory.

Jump to

Keyboard shortcuts

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