Documentation
¶
Overview ¶
Package patricia is an implementation of a PATRICIA Tree.
It has the three basic operations (insertion, lookup and deletion) plus some additional methods, notably one that allows a dynamic lookup based on delimiters, which works similar to a named parameter functionality in HTTP routers.
Example ¶
package main
import (
"fmt"
"github.com/gbrlsnchs/patricia"
)
func main() {
// Example from https://upload.wikimedia.org/wikipedia/commons/a/ae/Patricia_trie.svg.
t := patricia.New("Example")
t.Add("romane", 1)
t.Add("romanus", 2)
t.Add("romulus", 3)
t.Add("rubens", 4)
t.Add("ruber", 5)
t.Add("rubicon", 6)
t.Add("rubicundus", 7)
n := t.Get("romanus")
fmt.Println(n.Value)
}
Output: 2
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct {
// Value is a value of any type held by a node.
Value interface{}
// contains filtered or unexported fields
}
Node is a node of a PATRICIA tree.
type SortingTechnique ¶ added in v0.3.0
type SortingTechnique uint8
SortingTechnique is the technique used to sort the tree.
const ( // AscLabelSort is the value for sorting // the tree's edges by label in ascending order. AscLabelSort SortingTechnique = iota // DescLabelSort is the value for sorting // the tree's edges by label in descending order. DescLabelSort // PrioritySort is the value for sorting // the tree's edges by the priority of their nodes. PrioritySort )
Click to show internal directories.
Click to hide internal directories.