Documentation
¶
Overview ¶
Contains functions for sorting generic map[K]V by keys or by values, or using function. It returns []MapItem[K, V].
Index ¶
- func Clone[M ~map[K]V, K comparable, V any](m M) (M, error)
- func Copy[M ~map[K]V, K comparable, V any](m M) M
- func EqualJson[M1 ~map[K]V, M2 ~map[K]V, K comparable, V comparable](m1 M1, m2 M2) (bool, error)
- func From[K comparable, V any](value any) (res map[K]V, err error)
- func FromSlice[T any, K comparable, V any](s []T, f func(i int) (K, V)) (res map[K]V)
- func Get[R any](m any, key string) (R, error)
- func GetAny(m any, key string) (any, bool)
- func GetAnyOrDefault(m any, key string, default_ any) any
- func GetAnyOrDefaultWithSep(m any, key string, sep string, default_ any) any
- func GetAnyWithSep(m any, key string, sep string) (res any, ok bool)
- func GetOrDefault[R any](m any, key string, default_ R) R
- func GetOrDefaultWithSep[R any](m any, key string, sep string, default_ R) R
- func GetWithSep[R any](m any, key string, sep string) (res R, err error)
- func Keys[M ~map[K]V, K comparable, V any](m M) []K
- func Make[M ~map[K]V, K comparable, V any](m M, args ...int) M
- func MustGet[R any](m any, key string) R
- func Print[M ~map[K]V, K comparable, V any](m M, opts ...PrintOpts) error
- func Set(m any, key string, value any) (nm any, err error)
- func SetFloat32(m any, key string, value float32) (nm any, err error)
- func SetFloat64(m any, key string, value float64) (nm any, err error)
- func SetInt(m any, key string, value int) (nm any, err error)
- func SetInt8(m any, key string, value int8) (nm any, err error)
- func SetInt16(m any, key string, value int16) (nm any, err error)
- func SetInt32(m any, key string, value int32) (nm any, err error)
- func SetInt64(m any, key string, value int64) (nm any, err error)
- func SetString(m any, key string, value string) (nm any, err error)
- func SetUint(m any, key string, value uint) (nm any, err error)
- func SetUint8(m any, key string, value uint8) (nm any, err error)
- func SetUint16(m any, key string, value uint16) (nm any, err error)
- func SetUint32(m any, key string, value uint32) (nm any, err error)
- func SetUint64(m any, key string, value uint64) (nm any, err error)
- func SetWithSep(m any, key string, value any, sep string) (nm any, err error)
- func Size[M ~map[K]V, K comparable, V any](m M) (int64, error)
- func Sort[M ~map[K]V, K comparable, V any](m M) []gtypes.MapItem[K, V]
- func SortByFunc[M ~map[K]V, K comparable, V any](m M, f func(p1, p2 gtypes.MapItem[K, V]) bool) []gtypes.MapItem[K, V]
- func SortByFuncReverse[M ~map[K]V, K comparable, V any](m M, f func(p1, p2 gtypes.MapItem[K, V]) bool) []gtypes.MapItem[K, V]
- func SortByKey[M ~map[K]V, K comparable, V any](m M) []gtypes.MapItem[K, V]
- func SortByKeyReverse[M ~map[K]V, K comparable, V any](m M) []gtypes.MapItem[K, V]
- func SortByValue[M ~map[K]V, K comparable, V any](m M) []gtypes.MapItem[K, V]
- func SortByValueReverse[M ~map[K]V, K comparable, V any](m M) []gtypes.MapItem[K, V]
- func SortReverse[M ~map[K]V, K comparable, V any](m M) []gtypes.MapItem[K, V]
- func Sprint[M ~map[K]V, K comparable, V any](m M, opts ...PrintOpts) string
- func TrySprint[M ~map[K]V, K comparable, V any](m M, opts ...PrintOpts) (string, error)
- func Unroll[M ~map[K]V, K comparable, V any](m M) []gtypes.MapItem[string, any]
- func Unroll3[M ~map[K]V, K comparable, V any](m M) []gtypes.MapItem[string, any]
- func Values[M ~map[K]V, K comparable, V any](m M) []V
- func Visit[M ~map[K]V, K comparable, V any](m M, f func(v any, keys []string))
- type PrintOpts
- type SafeMap
- func (s *SafeMap[K, V]) Clear()
- func (s *SafeMap[K, V]) CompareAndDelete(k K, old V) (deleted bool)
- func (s *SafeMap[K, V]) CompareAndSwap(k K, old V, new V) (swapped bool)
- func (s *SafeMap[K, V]) Delete(k K)
- func (s *SafeMap[K, V]) Load(k K) (v V, ok bool)
- func (s *SafeMap[K, V]) LoadAndDelete(k K) (v V, loaded bool)
- func (s *SafeMap[K, V]) LoadOrStore(k K, v V) (r V, loaded bool)
- func (s *SafeMap[K, V]) Store(k K, v V)
- func (s *SafeMap[K, V]) Swap(k K, v V) (old V, loaded bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
func Clone[M ~map[K]V, K comparable, V any](m M) (M, error)
func Copy ¶
func Copy[M ~map[K]V, K comparable, V any](m M) M
func EqualJson ¶
func EqualJson[M1 ~map[K]V, M2 ~map[K]V, K comparable, V comparable](m1 M1, m2 M2) (bool, error)
func FromSlice ¶
func FromSlice[T any, K comparable, V any](s []T, f func(i int) (K, V)) (res map[K]V)
func GetAnyOrDefaultWithSep ¶
func GetOrDefault ¶
func GetOrDefaultWithSep ¶
func Keys ¶
func Keys[M ~map[K]V, K comparable, V any](m M) []K
func Make ¶
func Make[M ~map[K]V, K comparable, V any](m M, args ...int) M
func Sort ¶
func Sort[M ~map[K]V, K comparable, V any]( m M, ) []gtypes.MapItem[K, V]
Sort function sorts a map by keys
func SortByFunc ¶
func SortByFunc[M ~map[K]V, K comparable, V any]( m M, f func(p1, p2 gtypes.MapItem[K, V]) bool, ) []gtypes.MapItem[K, V]
SortByFunc function sorts a map using a function
func SortByFuncReverse ¶
func SortByFuncReverse[M ~map[K]V, K comparable, V any]( m M, f func(p1, p2 gtypes.MapItem[K, V]) bool, ) []gtypes.MapItem[K, V]
SortByFuncReverse function sorts a map using a function (reverse order)
func SortByKey ¶
func SortByKey[M ~map[K]V, K comparable, V any]( m M, ) []gtypes.MapItem[K, V]
SortByKey function sorts a map by keys
func SortByKeyReverse ¶
func SortByKeyReverse[M ~map[K]V, K comparable, V any]( m M, ) []gtypes.MapItem[K, V]
SortByKeyReverse function sorts a map by keys (reverse order)
func SortByValue ¶
func SortByValue[M ~map[K]V, K comparable, V any]( m M, ) []gtypes.MapItem[K, V]
SortByValue function sorts a map by values
func SortByValueReverse ¶
func SortByValueReverse[M ~map[K]V, K comparable, V any]( m M, ) []gtypes.MapItem[K, V]
SortByValue function sorts a map by values (reverse order)
func SortReverse ¶
func SortReverse[M ~map[K]V, K comparable, V any]( m M, ) []gtypes.MapItem[K, V]
SortReverse function sort a map by keys (reverse order)
func TrySprint ¶
func TrySprint[M ~map[K]V, K comparable, V any](m M, opts ...PrintOpts) (string, error)
func Values ¶
func Values[M ~map[K]V, K comparable, V any](m M) []V
Types ¶
type SafeMap ¶
type SafeMap[K comparable, V any] struct { // contains filtered or unexported fields }
func (*SafeMap[K, V]) CompareAndDelete ¶
func (*SafeMap[K, V]) CompareAndSwap ¶
func (*SafeMap[K, V]) LoadAndDelete ¶
func (*SafeMap[K, V]) LoadOrStore ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.