Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( AppName string = "armap" Version string = "1.7.1" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arena ¶ added in v1.2.0
type Arena interface {
Reset()
Release()
// contains filtered or unexported methods
}
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Example ¶
a := NewArena(2 * 1024 * 1024) // 2MB arena size
defer a.Release()
m := NewMap[string, string](a, WithCapacity(1000))
m.Set("hello", "world1")
v, ok := m.Get("hello")
fmt.Println(v, ok)
m.Set("hello", "world2")
v, ok = m.Get("hello")
fmt.Println(v, ok)
m.Clear()
_, ok = m.Get("hello")
fmt.Println(ok)
Output: world1 true world2 true false
func NewMap ¶ added in v1.1.0
func NewMap[K comparable, V any](arena Arena, funcs ...OptionFunc) *Map[K, V]
type OptionFunc ¶ added in v1.1.0
type OptionFunc func(*option)
func WithCapacity ¶ added in v1.2.0
func WithCapacity(size int) OptionFunc
func WithLoadFactor ¶ added in v1.2.0
func WithLoadFactor(rate float64) OptionFunc
type Set ¶ added in v1.1.0
type Set[K comparable] struct { // contains filtered or unexported fields }
Example ¶
a := NewArena(2 * 1024 * 1024) // 2MB arena size
defer a.Release()
s := NewSet[string](a, WithCapacity(1000))
ok := s.Add("foo")
fmt.Println("exists foo =", ok)
ok = s.Add("bar")
fmt.Println("exists bar =", ok)
ok = s.Contains("foo")
fmt.Println("contains foo =", ok)
ok = s.Add("foo")
fmt.Println("exists foo =", ok)
s.Clear()
ok = s.Add("foo")
fmt.Println("exists foo =", ok)
Output: exists foo = false exists bar = false contains foo = true exists foo = true exists foo = false
func NewSet ¶ added in v1.1.0
func NewSet[K comparable](arena Arena, funcs ...OptionFunc) *Set[K]
Click to show internal directories.
Click to hide internal directories.