syncmap

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 1 Imported by: 4

README

syncmap Go Reference Coverage Status

A generic wrapper around sync.Map.

How to use

package main

import (
    "log"

    "github.com/antoniomika/syncmap"
)

func main() {
    testMap := syncmap.New[string, string]()
    testMap.Store("foo", "bar")

    log.Println(testMap.Load("foo"))
}

Documentation

Overview

syncmap implements a generic synchronized map ontop of sync.Map.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

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

Map is a sync.Map wrapped in a generic manner.

func New

func New[K any, V any]() *Map[K, V]

New returns a new Map that is generic.

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(I K)

Delete will delete data from the Map.

func (*Map[K, V]) Load

func (m *Map[K, V]) Load(I K) (V, bool)

Load will load data from the Map.

func (*Map[K, V]) LoadAndDelete

func (m *Map[K, V]) LoadAndDelete(I K) (V, bool)

LoadAndDelete will load and delete data from the Map.

func (*Map[K, V]) LoadOrStore

func (m *Map[K, V]) LoadOrStore(I K, J V) (V, bool)

LoadOrStore will load or store data from the Map.

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(L func(I K, J V) bool)

Range will iterate over the data in the Map and apply the func on it.

func (*Map[K, V]) Store

func (m *Map[K, V]) Store(I K, J V)

Store will store data in the Map.

Jump to

Keyboard shortcuts

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