trie

package
v0.26.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitTLD

func SplitTLD(domain string) (label, rest string)

www.example.com -> ("com", "www.example")

Types

type SplitFunc

type SplitFunc func(string) (label, rest string)

type Trie

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

Trie stores a set of strings and can quickly check if it contains an element, or one of its parents.

It implements a semi-radix/semi-compressed trie: a node that would be a single child is merged with its parent, if it is a terminal.

The word "prefix" is avoided because in practice we use the `Trie` with `SplitTLD` so parents are suffixes even if in the datastructure they are prefixes.

func NewTrie

func NewTrie(split SplitFunc) *Trie

func (*Trie) HasParentOf

func (t *Trie) HasParentOf(key string) bool

func (*Trie) Insert

func (t *Trie) Insert(key string)

func (*Trie) IsEmpty

func (t *Trie) IsEmpty() bool

Jump to

Keyboard shortcuts

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