mapx

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 2 Imported by: 4

README

mapx

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmpty added in v1.0.2

func IsEmpty[M ~map[K]V, K comparable, V any](m M) bool

func IsNotEmpty added in v1.0.2

func IsNotEmpty[M ~map[K]V, K comparable, V any](m M) bool

Types

type Hash

type Hash[K comparable] interface {
	Sum(k K) int64
}

type Hash64Func

type Hash64Func[K comparable] func(k K) int64

func (Hash64Func[K]) Sum

func (f Hash64Func[K]) Sum(k K) int64

type Map

type Map[K comparable, V any] interface {
	Load(key K) (value V, ok bool)
	Store(key K, value V)
	LoadOrStore(key K, value V) (actual V, loaded bool)
	LoadAndDelete(key K) (value V, loaded bool)
	Delete(key K)
	DeleteFunc(del func(K, V) bool)
	Map() map[K]V
	Len() int
	Keys() []K
	Values() []V
	Clear()
	Clone() Map[K, V]
}

type SegmentMap

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

func NewSegmentMap

func NewSegmentMap[K comparable, V any](initSize int, shards int, hasher Hash[K]) *SegmentMap[K, V]

func (*SegmentMap[K, V]) Clear

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

func (*SegmentMap[K, V]) Clone

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

func (*SegmentMap[K, V]) Delete

func (m *SegmentMap[K, V]) Delete(key K)

func (*SegmentMap[K, V]) DeleteFunc

func (m *SegmentMap[K, V]) DeleteFunc(del func(K, V) bool)

func (*SegmentMap[K, V]) Keys

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

func (*SegmentMap[K, V]) Len

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

func (*SegmentMap[K, V]) Load

func (m *SegmentMap[K, V]) Load(key K) (value V, ok bool)

func (*SegmentMap[K, V]) LoadAndDelete

func (m *SegmentMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)

func (*SegmentMap[K, V]) LoadOrStore

func (m *SegmentMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

func (*SegmentMap[K, V]) Map

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

func (*SegmentMap[K, V]) Store

func (m *SegmentMap[K, V]) Store(key K, value V)

func (*SegmentMap[K, V]) Values

func (m *SegmentMap[K, V]) Values() []V

type StdMap

type StdMap[K comparable, V any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewStdMap

func NewStdMap[K comparable, V any](initSize int) *StdMap[K, V]

func (*StdMap[K, V]) Clear

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

func (*StdMap[K, V]) Clone

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

func (*StdMap[K, V]) Delete

func (m *StdMap[K, V]) Delete(key K)

func (*StdMap[K, V]) DeleteFunc

func (m *StdMap[K, V]) DeleteFunc(del func(K, V) bool)

func (*StdMap[K, V]) Keys

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

func (*StdMap[K, V]) Len

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

func (*StdMap[K, V]) Load

func (m *StdMap[K, V]) Load(key K) (value V, ok bool)

func (*StdMap[K, V]) LoadAndDelete

func (m *StdMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)

func (*StdMap[K, V]) LoadOrStore

func (m *StdMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

func (*StdMap[K, V]) Map

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

func (*StdMap[K, V]) Store

func (m *StdMap[K, V]) Store(key K, value V)

func (*StdMap[K, V]) Values

func (m *StdMap[K, V]) Values() []V

type SyncMap

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

func NewSyncMap

func NewSyncMap[K comparable, V any]() *SyncMap[K, V]

func (*SyncMap[K, V]) Clear

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

func (*SyncMap[K, V]) Clone

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

func (*SyncMap[K, V]) Delete

func (m *SyncMap[K, V]) Delete(key K)

func (*SyncMap[K, V]) DeleteFunc

func (m *SyncMap[K, V]) DeleteFunc(del func(K, V) bool)

func (*SyncMap[K, V]) Keys

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

func (*SyncMap[K, V]) Len

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

func (*SyncMap[K, V]) Load

func (m *SyncMap[K, V]) Load(key K) (value V, ok bool)

func (*SyncMap[K, V]) LoadAndDelete

func (m *SyncMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)

func (*SyncMap[K, V]) LoadOrStore

func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

func (*SyncMap[K, V]) Map

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

func (*SyncMap[K, V]) Store

func (m *SyncMap[K, V]) Store(key K, value V)

func (*SyncMap[K, V]) Values

func (m *SyncMap[K, V]) Values() []V

Jump to

Keyboard shortcuts

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