trie

package
v1.63.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDomain = errors.New("invalid domain")

ErrInvalidDomain means insert domain is invalid

Functions

func ValidAndSplitDomain

func ValidAndSplitDomain(domain string) ([]string, bool)

Types

type DomainTrie

type DomainTrie[T comparable] struct {
	// contains filtered or unexported fields
}

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

func New

func New[T comparable]() *DomainTrie[T]

New returns a new, empty Trie.

func (*DomainTrie[T]) Insert

func (t *DomainTrie[T]) Insert(domain string, data T) error

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

func (*DomainTrie[T]) Search

func (t *DomainTrie[T]) Search(domain string) *Node[T]

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

type Node

type Node[T comparable] struct {
	Data T
	// contains filtered or unexported fields
}

Node is the trie's node

Jump to

Keyboard shortcuts

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