Go Fast Object Map based on Murmur3 HashFunction
Clone or download
Latest commit f0e6d4f Jan 22, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
pkg add packages Jan 15, 2019
static done Jan 22, 2019
test docs Jan 22, 2019
.gitignore complete Jan 16, 2019
README.md add image Jan 22, 2019
murmur3map.go docs Jan 22, 2019

README.md

mumur3-map

Go Fast Object Map based on upon Murmur3

image

Usage

Example 1

	hashmap,_ := murmur3map.NewMap(100)
	hashmap.Set("keyforstring","Sample Text Value")
	val, _ := hashmap.Get("keyforstring")
	fmt.Println(val.Value)

Example 2

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

Feel free to fork or create pull request