kvs/main.go

46 lines
6.3 KiB
Go

package main
import (
"fmt"
"git.klmp200.net/klmp200/kvs/btree"
)
func main() {
// Example program
t := btree.NewBtree(3)
toInsert := [][]string{[]string{"climate", "change"}, []string{"machine", "doing"}, []string{"remember", "built"}, []string{"interest", "enjoy"}, []string{"no", "duty"}, []string{"contrast", "zoo"}, []string{"alike", "adventure"}, []string{"neck", "corn"}, []string{"union", "bark"}, []string{"elephant", "length"}, []string{"major", "light"}, []string{"interior", "camp"}, []string{"wind", "until"}, []string{"particles", "final"}, []string{"problem", "east"}, []string{"iron", "pattern"}, []string{"age", "personal"}, []string{"opportunity", "frog"}, []string{"goose", "sort"}, []string{"action", "effect"}, []string{"prevent", "stop"}, []string{"planned", "my"}, []string{"suit", "stood"}, []string{"orange", "forth"}, []string{"obtain", "door"}, []string{"list", "sink"}, []string{"official", "telephone"}, []string{"forest", "string"}, []string{"shade", "globe"}, []string{"city", "fighting"}, []string{"mixture", "line"}, []string{"mouth", "stomach"}, []string{"charge", "among"}, []string{"shorter", "spend"}, []string{"scale", "giant"}, []string{"spite", "image"}, []string{"evidence", "view"}, []string{"nobody", "hunter"}, []string{"cent", "recognize"}, []string{"everywhere", "avoid"}, []string{"handle", "influence"}, []string{"missing", "soft"}, []string{"strange", "seed"}, []string{"carry", "itself"}, []string{"route", "thought"}, []string{"about", "song"}, []string{"browserling", "compass"}, []string{"fort", "led"}, []string{"origin", "through"}, []string{"cover", "exciting"}, []string{"joined", "rod"}, []string{"dress", "highest"}, []string{"differ", "hall"}, []string{"slope", "discuss"}, []string{"fuel", "themselves"}, []string{"am", "final"}, []string{"straight", "constantly"}, []string{"eager", "carry"}, []string{"represent", "telephone"}, []string{"early", "something"}, []string{"young", "wagon"}, []string{"them", "late"}, []string{"space", "late"}, []string{"until", "industry"}, []string{"weigh", "president"}, []string{"fly", "power"}, []string{"average", "attempt"}, []string{"present", "rhyme"}, []string{"dear", "vowel"}, []string{"pay", "future"}, []string{"remarkable", "usual"}, []string{"brass", "type"}, []string{"blood", "began"}, []string{"size", "cat"}, []string{"around", "because"}, []string{"direction", "creature"}, []string{"lie", "blind"}, []string{"scientist", "effort"}, []string{"hardly", "dried"}, []string{"own", "fact"}, []string{"say", "direction"}, []string{"highest", "stronger"}, []string{"wait", "gently"}, []string{"old", "highway"}, []string{"eight", "four"}, []string{"active", "bread"}, []string{"square", "show"}, []string{"neighborhood", "cloud"}, []string{"flew", "separate"}, []string{"occur", "tower"}, []string{"forty", "heading"}, []string{"control", "move"}, []string{"carried", "interior"}, []string{"total", "found"}, []string{"strike", "nearby"}, []string{"mind", "talk"}, []string{"letter", "cost"}, []string{"theory", "stepped"}, []string{"remain", "fifteen"}, []string{"newspaper", "hot"}, []string{"beautiful", "arrive"}, []string{"compound", "stock"}, []string{"native", "putting"}, []string{"nodded", "sentence"}, []string{"more", "event"}, []string{"load", "nodded"}, []string{"aboard", "nation"}, []string{"continent", "work"}, []string{"buffalo", "locate"}, []string{"hunt", "outline"}, []string{"wealth", "till"}, []string{"smoke", "its"}, []string{"pair", "swim"}, []string{"necessary", "border"}, []string{"leaf", "label"}, []string{"round", "production"}, []string{"our", "wide"}, []string{"stairs", "trade"}, []string{"known", "plus"}, []string{"chose", "stronger"}, []string{"ear", "flame"}, []string{"pride", "spring"}, []string{"plates", "two"}, []string{"accurate", "sister"}, []string{"learn", "music"}, []string{"wrong", "gold"}, []string{"climate", "coffee"}, []string{"traffic", "fence"}, []string{"maybe", "aid"}, []string{"pilot", "spent"}, []string{"look", "silver"}, []string{"stretch", "book"}, []string{"back", "tea"}, []string{"wherever", "before"}, []string{"verb", "indeed"}, []string{"enemy", "bush"}, []string{"current", "may"}, []string{"be", "cover"}, []string{"task", "seldom"}, []string{"help", "typical"}, []string{"moon", "during"}, []string{"arm", "come"}, []string{"event", "shape"}, []string{"she", "needs"}, []string{"never", "nobody"}, []string{"couple", "corn"}, []string{"chance", "see"}, []string{"decide", "country"}, []string{"community", "adjective"}, []string{"none", "disappear"}, []string{"grandfather", "talk"}, []string{"white", "tank"}, []string{"attention", "early"}, []string{"sand", "score"}, []string{"speed", "friendly"}, []string{"however", "typical"}, []string{"mix", "medicine"}, []string{"support", "dozen"}, []string{"swim", "ahead"}, []string{"little", "most"}, []string{"still", "recent"}, []string{"anyone", "slipped"}, []string{"explore", "gold"}, []string{"coast", "thousand"}, []string{"written", "gather"}, []string{"heart", "somewhere"}, []string{"yard", "means"}, []string{"being", "at"}, []string{"pine", "repeat"}, []string{"kill", "rope"}, []string{"riding", "arrive"}, []string{"tune", "pile"}, []string{"nervous", "shake"}, []string{"married", "actual"}, []string{"desk", "speak"}, []string{"least", "hurried"}, []string{"coach", "guess"}, []string{"cutting", "cover"}, []string{"most", "establish"}, []string{"view", "back"}, []string{"duck", "tea"}, []string{"minute", "market"}, []string{"valley", "hurried"}, []string{"tea", "pressure"}, []string{"possible", "troops"}, []string{"ship", "dish"}, []string{"needle", "pour"}, []string{"creature", "death"}, []string{"behind", "swung"}, []string{"each", "circus"}, []string{"animal", "dog"}, []string{"potato", "fries"}, []string{"6", "number"}, []string{"12", "number"}, []string{"car", "ferrari"}, []string{"7", "number"}, []string{"plane", "airbus"}}
for _, k := range toInsert {
t.Insert(k[0], k[1])
}
s, _ := t.Search("animal")
fmt.Println(s)
t.Insert("animal", "cat")
s, _ = t.Search("animal")
fmt.Println(s)
fmt.Print("Traversal of the constructed tree is")
t.Traverse()
fmt.Println("")
t.Visualize()
if val, err := t.Search("6"); err != nil {
fmt.Print("\nNot Present")
} else {
fmt.Printf("\nPresent: value '%s'", val)
}
if val, err := t.Search("15"); err != nil {
fmt.Print("\nNot Present")
} else {
fmt.Printf("\nPresent: value '%s'", val)
}
}