syncx

package module
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 4 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

syncx

Documentation

Index

Constants

View Source
const (
	ErrBrokenRange = stringError("range was broken")
	ErrNilMap      = stringError("map is nil")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

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

Map is a synchronized map.

func NewMap

func NewMap[K constraints.Ordered, V any](m map[K]V) *Map[K, V]

NewMap returns a new Map from the given map. If the map is nil, a new map is created.

func (*Map[K, V]) BulkSet added in v1.4.0

func (m *Map[K, V]) BulkSet(kvs map[K]V) error

func (*Map[K, V]) Clear

func (m *Map[K, V]) Clear()

Clear removes all items from the map.

func (*Map[K, V]) Clone added in v1.1.0

func (m *Map[K, V]) Clone() (*Map[K, V], error)

Clone returns a new Map with a copy of the underlying map.

func (*Map[K, V]) Delete

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

Delete removes the item for the given key. Returns true if an item was in the map and deleted.

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(k K) (V, bool)

Get returns the value for the given key. Returns false if the key does not exist in the map.

func (*Map[K, V]) Keys

func (m *Map[K, V]) Keys() []K

Keys returns a sorted slice of the keys in the map.

func (*Map[K, V]) Len

func (m *Map[K, V]) Len() int

Len returns the number of items in the map.

func (*Map[K, V]) Map added in v1.5.0

func (m *Map[K, V]) Map() map[K]V

func (*Map[K, V]) MarshalJSON added in v1.5.1

func (m *Map[K, V]) MarshalJSON() ([]byte, error)

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(f func(k K, v V) bool) bool

Range calls f sequentially for each key and value present in the map. Returning true from f will terminate the iteration.

func (*Map[K, V]) Set

func (m *Map[K, V]) Set(k K, v V) error

Set sets the value for the given key.

func (*Map[K, V]) UnmarshalJSON added in v1.5.1

func (m *Map[K, V]) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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