hashmap

package
v0.0.0-...-6b6cd0b Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

implentation of a safe concurrent generic map

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashMap

type HashMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

HashMap is a generic implementation of a safe map. K is the key and V is the value.

Important for multiple concurrent reads and few writes. since it's guarded by sync.RWMutex

func NewHashMap

func NewHashMap[K comparable, V any]() *HashMap[K, V]

Instantiates a new AsyncMap.

func (*HashMap[K, V]) Clear

func (s *HashMap[K, V]) Clear()

deletes all elements in the map

func (*HashMap[K, V]) Contains

func (s *HashMap[K, V]) Contains(key K) bool

Returns true if key in map

func (*HashMap[K, V]) Delete

func (s *HashMap[K, V]) Delete(key K)

deletes the element with the specified key

func (*HashMap[K, V]) Get

func (s *HashMap[K, V]) Get(key K) (V, bool)

Returns V and true if key in map.

func (*HashMap[K, V]) IsEmpty

func (s *HashMap[K, V]) IsEmpty() bool

Returns true is map has zero elements

func (*HashMap[K, V]) Keys

func (s *HashMap[K, V]) Keys() []K

Returns a slice of the keys in the map

func (*HashMap[K, V]) Len

func (s *HashMap[K, V]) Len() int

deletes all elements in the map

func (*HashMap[K, V]) Set

func (s *HashMap[K, V]) Set(key K, value V)

Inserts V in map under the key

func (*HashMap[K, V]) Values

func (s *HashMap[K, V]) Values() []V

Returns a slice of all the values in the map This function copies the underlying data, so it is safe to use after the map has been modified.

Jump to

Keyboard shortcuts

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