Documentation
¶
Index ¶
- func DeepClone[T any](v T) T
- func DeepCopy(dst, src interface{})
- func RandGroup(p ...uint32) int
- func RandInterval(b1, b2 int32) int32
- func RandIntervalN(b1, b2 int32, n uint32) []int32
- type Map
- func (m *Map[K, V]) Del(key K)
- func (m *Map[K, V]) Get(key K) V
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) LockRange(f func(K, V))
- func (m *Map[K, V]) RLockRange(f func(K, V))
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) TestAndSet(key K, value V) V
- func (m *Map[K, V]) UnsafeDel(key K)
- func (m *Map[K, V]) UnsafeGet(key K) V
- func (m *Map[K, V]) UnsafeLen() int
- func (m *Map[K, V]) UnsafeRange(f func(K, V))
- func (m *Map[K, V]) UnsafeSet(key K, value V)
- type Semaphore
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandGroup ¶
Example ¶
package main
import (
"fmt"
"github.com/taills/leaf/v2/util"
)
func main() {
i := util.RandGroup(0, 0, 50, 50)
switch i {
case 2, 3:
fmt.Println("ok")
}
}
Output: ok
func RandInterval ¶
Example ¶
package main
import (
"fmt"
"github.com/taills/leaf/v2/util"
)
func main() {
v := util.RandInterval(-1, 1)
switch v {
case -1, 0, 1:
fmt.Println("ok")
}
}
Output: ok
Types ¶
type Map ¶
type Map[K comparable, V any] struct { sync.RWMutex // contains filtered or unexported fields }
Example ¶
package main
import (
"fmt"
"github.com/taills/leaf/v2/util"
)
func main() {
m := new(util.Map[any, any])
fmt.Println(m.Get("key"))
m.Set("key", "value")
fmt.Println(m.Get("key"))
m.Del("key")
fmt.Println(m.Get("key"))
m.Set(1, "1")
m.Set(2, 2)
m.Set("3", 3)
fmt.Println(m.Len())
}
Output: <nil> value <nil> 3
func (*Map[K, V]) RLockRange ¶
func (m *Map[K, V]) RLockRange(f func(K, V))
func (*Map[K, V]) TestAndSet ¶
func (m *Map[K, V]) TestAndSet(key K, value V) V
func (*Map[K, V]) UnsafeRange ¶
func (m *Map[K, V]) UnsafeRange(f func(K, V))
Click to show internal directories.
Click to hide internal directories.