File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments