Skip to content

Commit d0fe2f0

Browse files
committed
Adding README
1 parent 59b4e6d commit d0fe2f0

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

���README.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
go-radix [![Build Status](https://travis-ci.org/armon/radix.png)](https://travis-ci.org/armon/radix)
2+
=========
3+
4+
Provides the `radix` package that implements a [radix tree](http://en.wikipedia.org/wiki/Radix_tree).
5+
The package only provides a single `Tree` implementation, optimized for sparse nodes.
6+
7+
As 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+
13+
Example
14+
=======
15+
16+
Below is a simple example of usage
17+
18+
```go
19+
// Create a tree
20+
r := radix.New()
21+
r.Insert("foo", 1)
22+
r.Insert("bar", 2)
23+
r.Insert("foobar", 2)
24+
25+
// Find the longest prefix match
26+
m, _, _ := r.LongestPrefix("foozip")
27+
if m != "foo" {
28+
panic("should be foo")
29+
}
30+
```
31+

0 commit comments

Comments
 (0)