trie

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package trie provides Trie data structures in golang.

Wikipedia: https://en.wikipedia.org/wiki/Trie

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

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

Node represents each node in Trie.

Example
// creates a new node
node := NewNode()

// adds words
node.Insert("nikola")
node.Insert("tesla")

// finds words
node.Find("thomas") // false
node.Find("edison") // false
node.Find("nikola") // true

func NewNode

func NewNode() *Node

NewNode creates a new Trie node with initialized children map.

func (*Node) Find

func (n *Node) Find(s string) bool

Find finds words at a Trie node.

func (*Node) Insert

func (n *Node) Insert(s string)

Insert inserts words at a Trie node.

Jump to

Keyboard shortcuts

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