kvs/main.go

49 lines
800 B
Go
Raw Normal View History

package main
import (
"fmt"
"git.klmp200.net/klmp200/kvs/btree"
)
func main() {
2019-07-30 23:19:09 +00:00
// Example program
t := btree.NewBtree(3)
2019-07-30 23:19:09 +00:00
t.Insert("animal", "dog")
2019-07-31 12:09:13 +00:00
s, _ := t.Search("animal")
fmt.Println(s)
2019-07-30 23:19:09 +00:00
t.Insert("potato", "fries")
t.Insert("6", "number")
t.Insert("12", "number")
t.Insert("car", "ferrari")
t.Insert("7", "number")
t.Insert("plane", "airbus")
2019-07-31 12:09:13 +00:00
t.Insert("animal", "cat")
s, _ = t.Search("animal")
fmt.Println(s)
fmt.Print("Traversal of the constructed tree is")
t.Traverse()
2019-07-31 12:09:13 +00:00
fmt.Println("")
t.Visualize()
2019-07-30 23:19:09 +00:00
if val, err := t.Search("6"); err != nil {
fmt.Print("\nNot Present")
2019-07-30 23:19:09 +00:00
} else {
fmt.Printf("\nPresent: value '%s'", val)
}
2019-07-30 23:19:09 +00:00
if val, err := t.Search("15"); err != nil {
fmt.Print("\nNot Present")
2019-07-30 23:19:09 +00:00
} else {
fmt.Printf("\nPresent: value '%s'", val)
}
2019-07-31 12:09:13 +00:00
}