trie

package
v0.0.0-...-9a4d6f5 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidDomain means insert domain is invalid
	ErrInvalidDomain = errors.New("invalid domain")
)

Functions

This section is empty.

Types

type Node

type Node struct {
	Data interface{}
	// contains filtered or unexported fields
}

Node is the trie's node

type Trie

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

Trie contains the main logic for adding and searching nodes for domain segments. support wildcard domain (e.g *.google.com)

func New

func New() *Trie

New returns a new, empty Trie.

func (*Trie) Insert

func (t *Trie) Insert(domain string, data interface{}) error

Insert adds a node to the trie. Support 1. www.example.com 2. *.example.com 3. subdomain.*.example.com

func (*Trie) Search

func (t *Trie) Search(domain string) *Node

Search is the most important part of the Trie. Priority as: 1. static part 2. wildcard domain

Jump to

Keyboard shortcuts

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