https://github.com/sbromberger/lpmap
Linear probing hashmaps for Go
https://github.com/sbromberger/lpmap
Last synced: about 1 month ago
JSON representation
Linear probing hashmaps for Go
- Host: GitHub
- URL: https://github.com/sbromberger/lpmap
- Owner: sbromberger
- License: mit
- Created: 2022-11-06T18:16:37.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-07T16:10:32.000Z (over 2 years ago)
- Last Synced: 2025-01-22T08:13:47.075Z (3 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# lpmap: linear probing hash tables in Go
This is a generic implementation of linear probing hash tables in Go.
Example:
```go
type MyKey uint64func (k MyKey) Hash uint64 {
return k
}
func main() {
h := lpmap.New[MyKey, string](10, 0.5) // capacity of 10, with a max load factor of 0.5
h.Set(MyKey(9), "nine")
val, found := h.Get(MyKey(9)) // "nine", true
val, found = h.Get(MyKey(1)) // nil, false
h.Set(MyKey(9)) = "four" // replace value
h.Size() // 1
success := h.Delete(MyKey(9)) // true
h.Size() // 0
```