refactoring again, implementing b+tree

This commit is contained in:
Jae Kwon
2014-05-23 23:11:22 -07:00
parent 98c6181de0
commit ef480bb229
5 changed files with 659 additions and 109 deletions

View File

@ -5,35 +5,6 @@ import (
"fmt"
)
func Iterator(node Node) NodeIterator {
stack := make([]Node, 0, 10)
var cur Node = node
var itr NodeIterator
itr = func()(tn Node) {
if len(stack) > 0 || cur != nil {
for cur != nil {
stack = append(stack, cur)
cur = cur.Left(nil)
}
stack, cur = pop(stack)
tn = cur
cur = cur.Right(nil)
return tn
} else {
return nil
}
}
return itr
}
func pop(stack []Node) ([]Node, Node) {
if len(stack) <= 0 {
return stack, nil
} else {
return stack[0:len(stack)-1], stack[len(stack)-1]
}
}
func PrintIAVLNode(node *IAVLNode) {
fmt.Println("==== NODE")
printIAVLNode(node, 0)
@ -68,3 +39,10 @@ func randstr(length int) String {
panic("unreachable")
}
func maxUint8(a, b uint8) uint8 {
if a > b {
return a
}
return b
}