https://github.com/flouthoc/murmur3-map
Go Fast Object Map based on Murmur3 HashFunction
https://github.com/flouthoc/murmur3-map
golang golang-package hash hashmap murmur3 object
Last synced: 7 months ago
JSON representation
Go Fast Object Map based on Murmur3 HashFunction
- Host: GitHub
- URL: https://github.com/flouthoc/murmur3-map
- Owner: flouthoc
- Created: 2019-01-15T04:43:54.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-11T11:01:50.000Z (about 7 years ago)
- Last Synced: 2025-07-26T03:21:31.627Z (7 months ago)
- Topics: golang, golang-package, hash, hashmap, murmur3, object
- Language: Go
- Homepage:
- Size: 2.78 MB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mumur3-map
Go Fast Object Map based on upon Murmur3

## Usage
Example 1
```go
hashmap,_ := murmur3map.NewMap(100)
hashmap.Set("keyforstring","Sample Text Value")
val, _ := hashmap.Get("keyforstring")
fmt.Println(val.Value)
```
Example 2
```go
type sampletype struct{
name string
}
func main(){
hashmap,_ := murmur3map.NewMap(100)
sampletype_instance := new(sampletype)
sampletype_instance.name = "my name is flouthoc"
hashmap.Set("keyforobject", sampletype_instance)
valtwo,_ := hashmap.Get("keyforobject")
obj2,_ := valtwo.Value.(*sampletype)
fmt.Println(obj2.name)
}
```
## Docs
#### func NewMap(size int) (*MurmurMap, error)
Allocates a new mumurmap with given size. Returns struct MurmurMap
#### func (h* MurmurMap) Set(key string, value interface{}) bool
Sets k-v pair in map. Keys are supposed to be strings. Values can be anything just be careful when you are fetching them back from the map , see example for usage.
#### func (h *MurmurMap) Get(key string)(*Node, bool)
Returns back the value corresponding to the specified key otherwise returns false.
Just be sure to cast value back to struct type when you are done with fetching. See Example for usage.
### References
* https://en.wikipedia.org/wiki/MurmurHash
* https://github.com/spaolacci/murmur3
### Feel free to fork or create pull request