From 1ac30a6923c3dc9c1b12f4f03690f40cdd5da3bc Mon Sep 17 00:00:00 2001 From: Chakib Benziane Date: Thu, 30 Nov 2017 10:50:04 +0100 Subject: [PATCH] export RBTree --- hashmap.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hashmap.go b/hashmap.go index 243ae9c..ae69aff 100644 --- a/hashmap.go +++ b/hashmap.go @@ -26,17 +26,17 @@ type rbTreeNode struct { collisions map[interface{}]interface{} } -type rbTree struct { +type RBTree struct { root *rbTreeNode hashFunc func(interface{}) uint64 } // New creates a new hash map with supplied hashing function -func New(hashFunc func(i interface{}) uint64) *rbTree { - return &rbTree{hashFunc: hashFunc} +func New(hashFunc func(i interface{}) uint64) *RBTree { + return &RBTree{hashFunc: hashFunc} } -func (rb *rbTree) Insert(key, value interface{}) { +func (rb *RBTree) Insert(key, value interface{}) { keyHash := rb.hashFunc(key) child := &rbTreeNode{ @@ -144,7 +144,7 @@ func insertCase5(node *rbTreeNode) { } } -func (rb *rbTree) Get(key interface{}) (value interface{}, found bool) { +func (rb *RBTree) Get(key interface{}) (value interface{}, found bool) { if rb.root == nil { return nil, false } @@ -164,7 +164,7 @@ func (rb *rbTree) Get(key interface{}) (value interface{}, found bool) { return } -func (rb *rbTree) Remove(key interface{}) (found bool) { +func (rb *RBTree) Remove(key interface{}) (found bool) { keyHash := rb.hashFunc(key) node, found := findByKeyHash(rb.root, key, keyHash) if !found {