Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] interface { Store(K, V) Clear() Delete(K) CompareAndDelete(key K, old V) (deleted bool) Swap(k K, new V) (previous V, loaded bool) CompareAndSwap(key K, old, new V) (swapped bool) Load(K) (V, bool) LoadAndDelete(K) (v V, loaded bool) LoadOrStore(K, V) (actual V, loaded bool) Range(func(K, V) bool) Len() int Keys() []K Values() []V }
func AsSmap ¶
func AsSmap[K comparable, V any, M ~map[K]V](m M) Map[K, V]
func AsXmap ¶
func AsXmap[K comparable, V any, M ~map[K]V](m M) Map[K, V]
func NewSmap ¶
func NewSmap[K comparable, V any]() Map[K, V]
func NewXmap ¶
func NewXmap[K comparable, V any]() Map[K, V]
type OnceOverride ¶ added in v0.2.1
type OnceOverride[T any] struct { // contains filtered or unexported fields }
OnceOverride holds a value that has an initial default and can be overridden once. After the first successful Set, further modifications are not allowed.
Example ¶
package main
import (
"fmt"
"github.com/xoctopus/x/syncx"
)
func main() {
v := syncx.NewOnceOverride("default")
fmt.Println(v.Value())
v.Set("override")
fmt.Println(v.Value())
v.Set("override2")
fmt.Println(v.Value())
}
Output: default override override
func NewOnceOverride ¶ added in v0.2.1
func NewOnceOverride[T any](defaultValue T) *OnceOverride[T]
func (*OnceOverride[T]) Set ¶ added in v0.2.1
func (o *OnceOverride[T]) Set(x T) bool
func (*OnceOverride[T]) Value ¶ added in v0.2.1
func (o *OnceOverride[T]) Value() T
type Set ¶
type Set[K comparable] struct { // contains filtered or unexported fields }
func NewSet ¶
func NewSet[K comparable](keys ...K) *Set[K]
Click to show internal directories.
Click to hide internal directories.