Documentation ¶
Index ¶
- type Map
- func (m *Map) Clear()
- func (m *Map) Delete(key string) (prev interface{}, deleted bool)
- func (m *Map) DeleteAccept(key string, accept func(prev interface{}, replaced bool) bool) (prev interface{}, deleted bool)
- func (m *Map) Get(key string) (value interface{}, ok bool)
- func (m *Map) Len() int
- func (m *Map) Range(iter func(key string, value interface{}) bool)
- func (m *Map) Set(key string, value interface{}) (prev interface{}, replaced bool)
- func (m *Map) SetAccept(key string, value interface{}, ...) (prev interface{}, replaced bool)
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 hashmap. Like map[string]interface{}, but sharded and thread-safe.
func New ¶
New returns a new hashmap with the specified capacity. This function is only needed when you must define a minimum capacity, otherwise just use:
var m shardmap.Map
func (*Map) Delete ¶
Delete deletes a value for a key. Returns the deleted value, or false when no value was assigned.
func (*Map) DeleteAccept ¶
func (m *Map) DeleteAccept( key string, accept func(prev interface{}, replaced bool) bool, ) (prev interface{}, deleted bool)
DeleteAccept deletes a value for a key. The "accept" function can be used to inspect the previous value, if any, and accept or reject the change. It's also provides a safe way to block other others from writing to the same shard while inspecting. Returns the deleted value, or false when no value was assigned.
func (*Map) Get ¶
Get returns a value for a key. Returns false when no value has been assign for key.
func (*Map) Range ¶
Range iterates overall all key/values. It's not safe to call or Set or Delete while ranging.
func (*Map) Set ¶
Set assigns a value to a key. Returns the previous value, or false when no value was assigned.
func (*Map) SetAccept ¶
func (m *Map) SetAccept( key string, value interface{}, accept func(prev interface{}, replaced bool) bool, ) (prev interface{}, replaced bool)
SetAccept assigns a value to a key. The "accept" function can be used to inspect the previous value, if any, and accept or reject the change. It's also provides a safe way to block other others from writing to the same shard while inspecting. Returns the previous value, or false when no value was assigned.