safeHashMap

package
v0.0.0-...-682d07f Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

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 concurrency safe hash map

func New

func New() *Map

New returns a new concurrency safe hash map

func (*Map) Add

func (m *Map) Add(key string, value interface{}) bool

Add inserts the key value pair to the map. If there is already a mapping it will be overwritten by the new value. It returns true if there was not yet a mapping.

func (*Map) Get

func (m *Map) Get(key string) (interface{}, bool)

Get returns if the key is present the value associated with it from the map and true. Otherwise the value type's zero value and false is returned

func (*Map) GetAll

func (m *Map) GetAll() []interface{}

GetAll returns all contained values

func (*Map) GetAllKeys

func (m *Map) GetAllKeys() []string

GetAllKeys returns all keys

func (*Map) GetOrAdd

func (m *Map) GetOrAdd(key string, value interface{}) (interface{}, bool)

GetOrAdd only inserts the key value pair to Map if there has not yet been a mapping for key. It first returns the already existing value associated with the key or otherwise the new value. The second return value is a boolean value which is true if the mapping has not yet been present.

func (*Map) Len

func (m *Map) Len() int

Len returns the number of elements in the map

func (*Map) Remove

func (m *Map) Remove(key string) (interface{}, bool)

Remove deletes the key value pair from the map. It returns the value and true if an element was deleted. Otherwise nil and false

Jump to

Keyboard shortcuts

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