Skip to content

Commit

Permalink
Merge pull request #41 from tigrato/delhashedkey
Browse files Browse the repository at this point in the history
Fix delete action when using hashed key
  • Loading branch information
cornelk authored Oct 11, 2019
2 parents 33e5882 + 87bf3a2 commit 4c85270
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions hashmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,24 @@ func (m *HashMap) DelHashedKey(hashedKey uintptr) {
return
}

_, element := m.indexElement(hashedKey)
// inline HashMap.searchItem()
var element *ListElement
ElementLoop:
for _, element = m.indexElement(hashedKey); element != nil; element = element.Next() {
if element.keyHash == hashedKey {

break ElementLoop

}

if element.keyHash > hashedKey {
return
}
}

if element == nil {
return
}

m.deleteElement(element)
list.Delete(element)
}
Expand Down

0 comments on commit 4c85270

Please sign in to comment.