add some unittests and bug fix

This commit is contained in:
hdt3213
2021-05-02 18:48:44 +08:00
parent 37779717e4
commit 9f3ac88b36
19 changed files with 256 additions and 146 deletions

View File

@@ -32,7 +32,7 @@ func (m *Map) IsEmpty() bool {
return len(m.keys) == 0
}
func (m *Map) Add(keys ...string) {
func (m *Map) AddNode(keys ...string) {
for _, key := range keys {
if key == "" {
continue
@@ -59,8 +59,8 @@ func getPartitionKey(key string) string {
return key[beg+1 : end]
}
// Get gets the closest item in the hash to the provided key.
func (m *Map) Get(key string) string {
// PickNode gets the closest item in the hash to the provided key.
func (m *Map) PickNode(key string) string {
if m.IsEmpty() {
return ""
}