hmap

package
v0.0.0-...-da98dff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2018 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package hmap implements a non-resizable concurrency-aware hash map.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is a non-resizable hash map. A single update operation and multiple read operations can be executed concurrently on the map, while multiple update operations cannot. In other words, only update operations need an external synchronization.

Store and Delete are update operations and Load and Range are read operations. StatBuckets and StatEntries are considered to be write operations, while they do not modify the map.

func NewMap

func NewMap(capacity uint, hasher func(key interface{}) uint32) (m *Map)

NewMap returns an empty hash map that maintain the given number of buckets. The function hasher is used to hash keys.

func (*Map) Delete

func (m *Map) Delete(key interface{})

Delete logically removes the given key and its associated value.

func (*Map) Load

func (m *Map) Load(key interface{}) (value interface{}, ok bool)

Load returns the value associated with the given key and true if the key exists. Otherwise, it returns nil and false.

func (*Map) Range

func (m *Map) Range(f func(key, value interface{}) bool)

Range iteratively applies the given function to each key-value pair until the function returns false.

func (*Map) StatBuckets

func (m *Map) StatBuckets() (capacity, largest uint)

StatBuckets returns the number of buckets and the number of keys in the largest bucket.

func (*Map) StatEntries

func (m *Map) StatEntries() (mapSize, deleted uint)

StatEntries returns the number of keys physically existing in the map and the number of logically deleted keys.

func (*Map) Store

func (m *Map) Store(key, value interface{})

Store sets the given value to the given key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL