dnscrypt-proxy/vendor/github.com/k-sone/critbitgo
Frank Denis 7740e9d3bc Update dep and deps 2018-08-10 01:39:33 +02:00
..
.travis.yml Update deps 2018-04-07 17:14:53 +02:00
CHANGES.md Deps update 2018-04-25 20:23:31 +02:00
LICENSE Update deps 2018-04-07 17:14:53 +02:00
README.md Update deps 2018-04-07 17:14:53 +02:00
critbit.go Deps update 2018-04-25 20:23:31 +02:00
map.go Update deps 2018-04-07 17:14:53 +02:00
net.go Deps update 2018-04-25 20:23:31 +02:00

README.md

Build Status

critbitgo

Crit-bit trees in golang and its applications.

This implementation extended to handle the key that contains a null character from C implementation.

Usage

// Create Trie
trie := critbitgo.NewTrie()

// Insert
trie.Insert([]byte("aa"), "value1")
trie.Insert([]byte("bb"), "value2")
trie.Insert([]byte("ab"), "value3")

// Get
v, ok := trie.Get([]byte("aa"))
fmt.Println(v, ok)    // -> value1 true

// Iterate containing keys
trie.Allprefixed([]byte{}, func(key []byte, value interface{}) bool {
    fmt.Println(key, value) // -> [97 97] value1
                            //    [97 98] value3
                            //    [98 98] value2
    return true
})

// Delete
v, ok = trie.Delete([]byte("aa"))
fmt.Println(v, ok)    // -> value1 true
v, ok = trie.Delete([]byte("aa"))
fmt.Println(v, ok)    // -> <nil> false

License

MIT