File: README.md

package info (click to toggle)
golang-github-derekparker-trie 0.0~git20200317.1fdf38b-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 92 kB
  • sloc: makefile: 3
file content (62 lines) | stat: -rw-r--r-- 968 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
[![GoDoc](https://godoc.org/github.com/derekparker/trie?status.svg)](https://godoc.org/github.com/derekparker/trie)

# Trie
Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.

## Usage

Create a Trie with:

```Go
t := trie.New()
```

Add Keys with:

```Go
// Add can take in meta information which can be stored with the key.
// i.e. you could store any information you would like to associate with
// this particular key.
t.Add("foobar", 1)
```

Find a key with:

```Go
node, ok := t.Find("foobar")
meta := node.Meta()
// use meta with meta.(type)
```

Remove Keys with:

```Go
t.Remove("foobar")
```

Prefix search with:

```Go
t.PrefixSearch("foo")
```

Fast test for valid prefix:
```Go
t.HasKeysWithPrefix("foo")
```

Fuzzy search with:

```Go
t.FuzzySearch("fb")
```

## Contributing
Fork this repo and run tests with:

	go test

Create a feature branch, write your tests and code and submit a pull request.

## License
MIT