From ab55b7508214686624c69c61a44cc5f6e0b48581 Mon Sep 17 00:00:00 2001 From: Brett Vickers Date: Sat, 6 Jul 2024 12:43:27 -0700 Subject: [PATCH] Update README to indicate branch's archive status --- README.md | 79 ++++--------------------------------------------------- 1 file changed, 5 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index 82b5e60..544e518 100644 --- a/README.md +++ b/README.md @@ -1,80 +1,11 @@ -[![GoDoc](https://godoc.org/github.com/beevik/prefixtree?status.svg)](https://godoc.org/github.com/beevik/prefixtree) +[![GoDoc](https://godoc.org/github.com/beevik/prefixtree?status.svg)](https://pkg.go.dev/github.com/beevik/prefixtree/v2) [![Go](https://github.com/beevik/prefixtree/actions/workflows/go.yml/badge.svg)](https://github.com/beevik/prefixtree/actions/workflows/go.yml) prefixtree ========== -The prefixtree package implements a simple prefix trie data structure. -The tree enables rapid searching for strings that uniquely match a given -prefix. The implementation allows the user to associate data with each -string, so it can act as a sort of flexible key-value store where -searches succeed with the shortest unambiguous key prefix. +This branch of `prefixtree` is archived and will receive no further updates. -### Example: Building a prefix tree - -The following code adds strings and associated data (in this case an integer) -to a prefix tree. - -```go -tree := prefixtree.New() - -tree.Add("apple", 10) -tree.Add("orange", 20) -tree.Add("apple pie", 30) -tree.Add("lemon", 40) -tree.Add("lemon meringue pie", 50) -``` - -### Example: Searching the prefix tree - -The following code searches the prefix tree generated by the -previous example and outputs the results. - -```go -fmt.Printf("%-18s %-8s %s\n", "prefix", "value", "error") -fmt.Printf("%-18s %-8s %s\n", "------", "-----", "-----") - -for _, prefix := range []string{ - "a", - "appl", - "apple", - "apple p", - "apple pie", - "apple pies", - "o", - "oran", - "orange", - "oranges", - "l", - "lemo", - "lemon", - "lemon m", - "lemon meringue", - "pear", -} { - value, err := tree.Find(prefix) - fmt.Printf("%-18s %-8v %v\n", prefix, value, err) -} -``` - -Output: -``` -prefix value error ------- ----- ----- -a prefixtree: prefix ambiguous -appl prefixtree: prefix ambiguous -apple 10 -apple p 30 -apple pie 30 -apple pies prefixtree: prefix not found -o 20 -orang 20 -orange 20 -oranges prefixtree: prefix not found -l prefixtree: prefix ambiguous -lemo prefixtree: prefix ambiguous -lemon 40 -lemon m 50 -lemon meringue 50 -pear prefixtree: prefix not found -``` +There is now a new [version `v2`](https://github.com/beevik/prefixtree/tree/v2) +of prefixtree, which uses a generic type instead of an empty interface to +represent its values. Please use this branch instead.