syncmap

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Temporary sync map replacement with generics until go 1.18 bakes a bit and one gets released.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Syncmap

type Syncmap[Key comparable, Value any] struct {
	// contains filtered or unexported fields
}

func New

func New[Key comparable, Value any]() Syncmap[Key, Value]

func (*Syncmap[Key, Value]) Delete

func (s *Syncmap[Key, Value]) Delete(key Key)

func (*Syncmap[Key, Value]) Get

func (s *Syncmap[Key, Value]) Get(key Key) (Value, bool)

func (*Syncmap[Key, Value]) Keys

func (s *Syncmap[Key, Value]) Keys() []Key

func (*Syncmap[Key, Value]) Set

func (s *Syncmap[Key, Value]) Set(key Key, value Value)

func (*Syncmap[Key, Value]) Swap

func (s *Syncmap[Key, Value]) Swap(key Key, fn func(value Value, exists bool) (Value, error)) error

Swap allows the caller to atomically swap a value utilizing a closure. Returning an error in the closure aborts the swap and returns the error to the main swap function.

Jump to

Keyboard shortcuts

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