Documentation
¶
Index ¶
- func ConvertTo[V any, R any](source Enumerable[V], convert func(V) R) []R
- func ConvertToWithIndex[V any, R any](source Enumerable[V], convert func(int, V) R) []R
- func ConvertToWithKey[K comparable, V any, R any](source EnumerableWithKey[K, V], convert func(K, V) R) []R
- type Enumerable
- type EnumerableWithKey
- type GoMap
- type Map
- type RWMutexMap
- func (m *RWMutexMap[K, V]) Data() map[K]V
- func (m *RWMutexMap[K, V]) Delete(key K)
- func (m *RWMutexMap[K, V]) DeleteAll()
- func (m *RWMutexMap[K, V]) Each(f func(key K, value V))
- func (m *RWMutexMap[K, V]) EachValue(f func(value V))
- func (m *RWMutexMap[K, V]) Exist(key K) (ok bool)
- func (m *RWMutexMap[K, V]) Get(key K) V
- func (m *RWMutexMap[K, V]) Keys() []K
- func (m *RWMutexMap[K, V]) Load(key K) (value V, ok bool)
- func (m *RWMutexMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)
- func (m *RWMutexMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
- func (m *RWMutexMap[K, V]) Range(f func(key K, value V) bool)
- func (m *RWMutexMap[K, V]) Size() int
- func (m *RWMutexMap[K, V]) Store(key K, value V)
- func (m *RWMutexMap[K, V]) Values() []V
- type SafeMap
- type Sizer
- type SyncMap
- func (s *SyncMap[K, V]) Data() map[K]V
- func (s *SyncMap[K, V]) Delete(key K)
- func (s *SyncMap[K, V]) DeleteAll()
- func (s *SyncMap[K, V]) Each(f func(key K, value V))
- func (s *SyncMap[K, V]) EachValue(f func(value V))
- func (s *SyncMap[K, V]) Exist(key K) (ok bool)
- func (s *SyncMap[K, V]) Get(key K) V
- func (s *SyncMap[K, V]) Keys() []K
- func (s *SyncMap[K, V]) Load(key K) (value V, ok bool)
- func (s *SyncMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)
- func (s *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
- func (s *SyncMap[K, V]) Range(f func(key K, value V) bool)
- func (s *SyncMap[K, V]) Size() int
- func (s *SyncMap[K, V]) Store(key K, value V)
- func (s *SyncMap[K, V]) Values() []V
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertTo ¶
func ConvertTo[V any, R any](source Enumerable[V], convert func(V) R) []R
Example ¶
data := map[string]int{}
data["a"] = 1
data["b"] = 2
data["c"] = 3
r := ConvertTo[int](GoMap[string, int](data), func(v int) string {
return strconv.Itoa(v)
})
fmt.Println(r)
Output: [1 2 3]
func ConvertToWithIndex ¶
func ConvertToWithIndex[V any, R any](source Enumerable[V], convert func(int, V) R) []R
func ConvertToWithKey ¶
func ConvertToWithKey[K comparable, V any, R any](source EnumerableWithKey[K, V], convert func(K, V) R) []R
Types ¶
type Enumerable ¶
type EnumerableWithKey ¶
type EnumerableWithKey[K comparable, V any] interface { Sizer Each(func(key K, value V)) }
type GoMap ¶
type GoMap[K comparable, V any] map[K]V
type RWMutexMap ¶
type RWMutexMap[K constraints.Basic, V any] struct { // contains filtered or unexported fields }
RWMutexMap implements the SafeMap[K,V] interface
func NewRWMutexMap ¶
func NewRWMutexMap[K constraints.Basic, V any]() *RWMutexMap[K, V]
func (*RWMutexMap[K, V]) Data ¶
func (m *RWMutexMap[K, V]) Data() map[K]V
func (*RWMutexMap[K, V]) Delete ¶
func (m *RWMutexMap[K, V]) Delete(key K)
func (*RWMutexMap[K, V]) DeleteAll ¶
func (m *RWMutexMap[K, V]) DeleteAll()
func (*RWMutexMap[K, V]) Each ¶
func (m *RWMutexMap[K, V]) Each(f func(key K, value V))
func (*RWMutexMap[K, V]) EachValue ¶
func (m *RWMutexMap[K, V]) EachValue(f func(value V))
func (*RWMutexMap[K, V]) Exist ¶
func (m *RWMutexMap[K, V]) Exist(key K) (ok bool)
func (*RWMutexMap[K, V]) Get ¶
func (m *RWMutexMap[K, V]) Get(key K) V
func (*RWMutexMap[K, V]) Keys ¶
func (m *RWMutexMap[K, V]) Keys() []K
func (*RWMutexMap[K, V]) Load ¶
func (m *RWMutexMap[K, V]) Load(key K) (value V, ok bool)
func (*RWMutexMap[K, V]) LoadAndDelete ¶
func (m *RWMutexMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)
func (*RWMutexMap[K, V]) LoadOrStore ¶
func (m *RWMutexMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
func (*RWMutexMap[K, V]) Range ¶
func (m *RWMutexMap[K, V]) Range(f func(key K, value V) bool)
func (*RWMutexMap[K, V]) Size ¶
func (m *RWMutexMap[K, V]) Size() int
func (*RWMutexMap[K, V]) Store ¶
func (m *RWMutexMap[K, V]) Store(key K, value V)
func (*RWMutexMap[K, V]) Values ¶
func (m *RWMutexMap[K, V]) Values() []V
type SyncMap ¶
type SyncMap[K constraints.Basic, V any] struct { // contains filtered or unexported fields }
SyncMap efficiency is lower than the sync.Map, only suitable for small maps
func NewSyncMap ¶
func NewSyncMap[K constraints.Basic, V any]() *SyncMap[K, V]
func (*SyncMap[K, V]) LoadAndDelete ¶
func (*SyncMap[K, V]) LoadOrStore ¶
Click to show internal directories.
Click to hide internal directories.