emirpasic 7 years ago
parent 17852f48a5
commit 370f7ab252

@ -64,6 +64,8 @@ func NewWithStringComparator() *Tree {
func (tree *Tree) Put(key interface{}, value interface{}) { func (tree *Tree) Put(key interface{}, value interface{}) {
var insertedNode *Node var insertedNode *Node
if tree.Root == nil { if tree.Root == nil {
// Assert key is of comparator's type for initial tree
tree.Comparator(key, key)
tree.Root = &Node{Key: key, Value: value, color: red} tree.Root = &Node{Key: key, Value: value, color: red}
insertedNode = tree.Root insertedNode = tree.Root
} else { } else {

Loading…
Cancel
Save