trie

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: GPL-3.0 Imports: 5 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 {
	Char        string
	Children    [26]*Node
	IsEndOfWord bool
	IsAlias     bool
	FileName    string
}

Node represents a single character in the trie. Char is the string repersentation of the character Each node has 26 childe nodes which represent each letter of the alphabet.

func NewNode

func NewNode(char string) *Node

NewNode is used to initialize a new node with it's 26 children and each child should first be initialized to nil

type Trie

type Trie struct {
	RootNode *Node
}

Trie is the tree that will hold all of the nodes. RootNode is always nil.

func Init added in v0.6.0

func Init(path string) (*Trie, error)

func NewTrie

func NewTrie() *Trie

NewTrie creates a new trie with a root. This node is not used to match words so it can be anything; ie "\000".

func (*Trie) InsertAlias added in v0.6.0

func (t *Trie) InsertAlias(alias, fileName string)

func (*Trie) InsertFileName added in v0.6.0

func (t *Trie) InsertFileName(fileName string)

Insert inserts a word to the trie.

func (*Trie) Search

func (t *Trie) Search(prefix string) []string

Jump to

Keyboard shortcuts

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