storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

type Storage[key any, val any] interface {
	// Add adds the specified node to the storage.
	// If the node already exists, it will be overwritten.
	Add(k key, v val)
	// Delete deletes the node associated with the specified id.
	Delete(k key)
	// Get returns the node associated with the specified id.
	Get(k key) (val, bool)
	// Exist returns true if the specified node exists in the storage.
	Exist(k key) bool
	// Tap calls the specified function for parallel each node in the storage.
	Tap(fn func(key, val))
}

Storage represents a storage for storing nodes.

type SyncMap

type SyncMap[key any, val any] struct {
	// contains filtered or unexported fields
}

func NewSyncMapStorage

func NewSyncMapStorage[key any, val any]() *SyncMap[key, val]

NewSyncMapStorage creates a new SyncMap.

func (*SyncMap[key, val]) Add

func (s *SyncMap[key, val]) Add(k key, v val)

func (*SyncMap[key, val]) Delete

func (s *SyncMap[key, val]) Delete(k key)

func (*SyncMap[key, val]) Exist

func (s *SyncMap[key, val]) Exist(k key) bool

func (*SyncMap[key, val]) Get

func (s *SyncMap[key, val]) Get(k key) (val, bool)

func (*SyncMap[key, val]) Tap

func (s *SyncMap[key, val]) Tap(fn func(key, val))

Jump to

Keyboard shortcuts

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