Documentation ¶
Index ¶
- Variables
- func Args(params ...interface{}) []interface{}
- func AutoLock(mu *sync.Mutex, fun func())
- func AutoRLock(mu *sync.RWMutex, fun func())
- func AutoWLock(mu *sync.RWMutex, fun func())
- func BoolComparator(a, b bool) int
- func Cast(condition bool, trueFun, falseFun func())
- func Catch(desc string, x interface{}, bFatal ...bool) bool
- func Clear[M ~map[K]V, K comparable, V any](m M)
- func Clone[M ~map[K]V, K comparable, V any](m M) M
- func Complex128Comparator(a, b complex128) int
- func Complex64Comparator(a, b complex64) int
- func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2)
- func DefaultVal[T any](vars []T) T
- func DeleteFunc[M ~map[K]V, K comparable, V any](m M, del func(K, V) bool)
- func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool
- func EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) bool
- func ExeFullName() string
- func ExeName() string
- func Float32Comparator(a, b float32) int
- func Float64Comparator(a, b float64) int
- func FuncFullName(fun interface{}, seps ...rune) string
- func FuncFullNameRef(valFun reflect.Value, seps ...rune) string
- func FuncName(fun interface{}) string
- func GoId() (int, error)
- func Goroutine(name string, goFun func(), wg ...*sync.WaitGroup)
- func Int16Comparator(a, b int16) int
- func Int32Comparator(a, b int32) int
- func Int64Comparator(a, b int64) int
- func Int8Comparator(a, b int8) int
- func IntComparator(a, b int) int
- func Keys[M ~map[K]V, K comparable, V any](m M) []K
- func Lock(mu *sync.Mutex) *sync.Mutex
- func OrderedTypeCmp[T Ordered](a, b T) int
- func Quit(delay ...time.Duration)
- func RLock(mu *sync.RWMutex) *sync.RWMutex
- func RUnLock(rMutex *sync.RWMutex)
- func Sleep(d time.Duration)
- func Stack(depth int) (file string, line int, fun string)
- func StringComparator(a, b string) int
- func StructName(obj interface{}) string
- func Term(clearHand func(interface{}))
- func Tern[T bool, U any](isTrue T, ifValue U, elseValue U) U
- func TimeLived() time.Duration
- func TimeStart() time.Time
- func Uint16Comparator(a, b uint16) int
- func Uint32Comparator(a, b uint32) int
- func Uint64Comparator(a, b uint64) int
- func Uint8Comparator(a, b uint8) int
- func UintComparator(a, b uint) int
- func UintptrComparator(a, b uintptr) int
- func UnLock(lockFun *sync.Mutex)
- func Values[M ~map[K]V, K comparable, V any](m M) []V
- func WLock(mu *sync.RWMutex) *sync.RWMutex
- func WUnLock(wMutex *sync.RWMutex)
- func Wait(x ...interface{})
- type Comparator
- type Complex
- type Float
- type HashMap
- func (m *HashMap[K, V]) Clear()
- func (m *HashMap[K, V]) Contains(keys ...K) bool
- func (m *HashMap[K, V]) Erase(key K)
- func (m *HashMap[K, V]) Find(key K) *Pair[K, V]
- func (m *HashMap[K, V]) Get(key K) (V, bool)
- func (m *HashMap[K, V]) Got(key K) V
- func (m *HashMap[K, V]) Insert(key K, value V)
- func (m *HashMap[K, V]) Inserts(pairs ...*Pair[K, V])
- func (m *HashMap[K, V]) Iterator(iterFunc func(key K, val V))
- func (m *HashMap[K, V]) Keys() []K
- func (m *HashMap[K, V]) Replace(data map[K]V)
- func (m *HashMap[K, V]) Size() int
- func (m *HashMap[K, V]) Values() []V
- type ILocker
- type IRWLocker
- type IntStringer
- type Integer
- type InvalidLocker
- type Locker
- type Option
- type Options
- type Ordered
- type Pair
- type RWLocker
- type Signed
- type UIntStringer
- type Unsigned
Constants ¶
This section is empty.
Variables ¶
var ErrorNotFound = errors.New("not found")
Functions ¶
func Clear ¶
func Clear[M ~map[K]V, K comparable, V any](m M)
Clear removes all entries from m, leaving it empty.
func Clone ¶
func Clone[M ~map[K]V, K comparable, V any](m M) M
Clone returns a copy of m. This is a shallow clone: the new keys and values are set using ordinary assignment.
func Complex128Comparator ¶
func Complex128Comparator(a, b complex128) int
Complex128Comparator compare a with b
-1 , if a < b 0 , if a == b 1 , if a > b
func Complex64Comparator ¶
Complex64Comparator compare a with b
-1 , if a < b 0 , if a == b 1 , if a > b
func Copy ¶
func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2)
Copy copies all key/value pairs in src adding them to dst. When a key in src is already present in dst, the value in dst will be overwritten by the value associated with the key in src.
func DefaultVal ¶
func DefaultVal[T any](vars []T) T
func DeleteFunc ¶
func DeleteFunc[M ~map[K]V, K comparable, V any](m M, del func(K, V) bool)
DeleteFunc deletes any key/value pairs from m for which del returns true.
func Equal ¶
func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool
Equal reports whether two maps contain the same key/value pairs. Values are compared using ==.
func EqualFunc ¶
func EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) bool
EqualFunc is like Equal, but compares values using eq. Keys are still compared with ==.
func ExeFullName ¶
func ExeFullName() string
func Float32Comparator ¶
Float32Comparator compare a with b
-1 , if a < b 0 , if a == b 1 , if a > b
func Float64Comparator ¶
Float64Comparator compare a with b
-1 , if a < b 0 , if a == b 1 , if a > b
func FuncFullName ¶
func Keys ¶
func Keys[M ~map[K]V, K comparable, V any](m M) []K
Keys returns the keys of the map m. The keys will be in an indeterminate order.
func OrderedTypeCmp ¶
func StructName ¶
func StructName(obj interface{}) string
func UintptrComparator ¶
UintptrComparator compare a with b
-1 , if a < b 0 , if a == b 1 , if a > b
func Values ¶
func Values[M ~map[K]V, K comparable, V any](m M) []V
Values returns the values of the map m. The values will be in an indeterminate order.
Types ¶
type Comparator ¶
Comparator Should return a number:
-1 , if a < b 0 , if a == b 1 , if a > b
func Reverse ¶
func Reverse[T any](cmp Comparator[T]) Comparator[T]
Reverse returns a comparator reverse to cmp
type Complex ¶
type Complex interface { ~complex64 | ~complex128 }
type HashMap ¶
type HashMap[K comparable, V any] struct { // contains filtered or unexported fields }
HashMap uses RbTress for internal data structure, and every key can must bee unique.
func NewHashMap ¶
func NewHashMap[K comparable, V any](opts ...Option) *HashMap[K, V]
New creates a new map
func (*HashMap[K, V]) Contains ¶
Contains returns true if the key is in the map. otherwise returns false.
func (*HashMap[K, V]) Erase ¶
func (m *HashMap[K, V]) Erase(key K)
Erase erases the node by the passed key from the map if the key in the Map
func (*HashMap[K, V]) Get ¶
Get returns the value of the passed key if the key is in the map, otherwise returns nil
func (*HashMap[K, V]) Got ¶
func (m *HashMap[K, V]) Got(key K) V
Got returns the value of the passed key if the key is in the map, otherwise returns nil
func (*HashMap[K, V]) Insert ¶
func (m *HashMap[K, V]) Insert(key K, value V)
Insert inserts a key-value to the map
type IRWLocker ¶
type IRWLocker interface { // 写锁 ILocker // 读锁 RLock() interface{} RUnLock(i interface{}) }
读写锁
type IntStringer ¶
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
==================== Locker
type Option ¶
type Option func(option *Options)
Option is a function type used to set Options
func HashMapWithSafe ¶
func HashMapWithSafe() Option
HashMapWithSafe is used to set a map goroutine-safe Note that iterators are not goroutine safe, and it is useless to turn on the setting option here. so don't use iterator in multi goroutines
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options holds Map's options
type Pair ¶
type Pair[K comparable, V any] struct { // contains filtered or unexported fields }
func MakePair ¶
func MakePair[K comparable, V any](key K, val V) *Pair[K, V]