• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D24-Aug-2018252

.travis.ymlH A D24-Aug-201825

LICENSEH A D24-Aug-20181.1 KiB

README.mdH A D24-Aug-20181 KiB

go.modH A D24-Aug-201833

radix.goH A D24-Aug-201810.4 KiB

radix_test.goH A D24-Aug-20186.1 KiB

README.md

1go-radix [![Build Status](https://travis-ci.org/armon/go-radix.png)](https://travis-ci.org/armon/go-radix)
2=========
3
4Provides the `radix` package that implements a [radix tree](http://en.wikipedia.org/wiki/Radix_tree).
5The package only provides a single `Tree` implementation, optimized for sparse nodes.
6
7As a radix tree, it provides the following:
8 * O(k) operations. In many cases, this can be faster than a hash table since
9   the hash function is an O(k) operation, and hash tables have very poor cache locality.
10 * Minimum / Maximum value lookups
11 * Ordered iteration
12
13For an immutable variant, see [go-immutable-radix](https://github.com/hashicorp/go-immutable-radix).
14
15Documentation
16=============
17
18The full documentation is available on [Godoc](http://godoc.org/github.com/armon/go-radix).
19
20Example
21=======
22
23Below is a simple example of usage
24
25```go
26// Create a tree
27r := radix.New()
28r.Insert("foo", 1)
29r.Insert("bar", 2)
30r.Insert("foobar", 2)
31
32// Find the longest prefix match
33m, _, _ := r.LongestPrefix("foozip")
34if m != "foo" {
35    panic("should be foo")
36}
37```
38
39