- red-black tree tests

- start on remove function of tree
pull/1/head
emirpasic 9 years ago
parent a4ce69b5af
commit e42a0a3ce8

@ -16,7 +16,8 @@ License along with this library. See the file LICENSE included
with this distribution for more information.
*/
// Implementation of Red-black tree
// Implementation of Red-black tree.
// Used by TreeSet and TreeMap.
// References: http://en.wikipedia.org/wiki/Red%E2%80%93black_tree
package redblacktree
@ -106,6 +107,15 @@ func (tree *Tree) Get(key interface{}) (interface{}, bool) {
return nil, false
}
func (tree *Tree) Remove(key interface{}) {
}
// Returns true if tree does not contain any nodes
func (tree *Tree) IsEmpty() bool {
return tree.root == nil
}
func (tree *Tree) lookup(key interface{}) *Node {
node := tree.root
for node != nil {

@ -4,7 +4,7 @@ import (
"testing"
)
func TestPut(t *testing.T) {
func TestPutGet(t *testing.T) {
tree := NewWithIntComparator()
@ -12,7 +12,7 @@ func TestPut(t *testing.T) {
tree.Put(4, "d")
tree.Put(1, "x")
tree.Put(2, "b")
tree.Put(1, "a")
tree.Put(1, "a") //overwrite
// key,expectedValue,expectedFound
tests := [][]interface{}{

Loading…
Cancel
Save