redblacktree:golang中的自平衡二叉搜索树
红黑树
。
用法
默认树期望键为int类型。
import (
"fmt"
rbt "github.com/erriapo/redblacktree"
)
func main () {
t := rbt . NewTree ()
t . Put ( 7 , "payload7" )
t . Put ( 3 , "payload3" )
t . Put ( 1 , "payload1" )
fmt . Printf ( "size = %d \n " , t . Size ()) // size = 3
inorder := & rbt. InorderVisitor {}; t . Walk ( inorder )
fmt . Printf ( "tree = %s \n " , inorder ) // tree