trie

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package trie provides an interface and implementations for the trie data structure

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Trie

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

Trie is a data structure for locating keys within a set but the key is broken into individual parts (e.g. a string broken into characters) and the key is access by traversing the trie depth-first.

func NewTrie

func NewTrie[T comparable]() *Trie[T]

NewTrie instantiates a trie and returns a pointer to it.

func (*Trie[T]) Contains

func (trie *Trie[T]) Contains(array []T) bool

Contains returns a Boolean that is true if the given key exists in the trie.

func (*Trie[T]) Insert

func (trie *Trie[T]) Insert(array []T) bool

Insert inserts a new key into the trie. It returns a Boolean that is true if the key was not already present in the trie.

func (*Trie[T]) Remove

func (trie *Trie[T]) Remove(array []T) bool

Remove will remove the given key from the trie.

type TrieNode

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

TrieNode is a node within the trie and contains a map of child nodes and a Boolean to say whether a key terminates at this node.

Jump to

Keyboard shortcuts

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