Documentation
¶
Index ¶
- Constants
- type Arena
- type LinkedList
- func (l *LinkedList[K, V]) Clear()
- func (l *LinkedList[K, V]) Delete(key K) (old V, found bool)
- func (l *LinkedList[K, V]) DeleteAll()
- func (l *LinkedList[K, V]) Get(key K) (old V, found bool)
- func (l *LinkedList[K, V]) Len() int
- func (l *LinkedList[K, V]) Push(key K, value V) (old V, found bool)
- func (l *LinkedList[K, V]) Scan(iter func(K, V) bool)
- type Map
- type OptionFunc
- type Set
- type TypeArena
Examples ¶
Constants ¶
View Source
const ( AppName string = "armap" Version string = "1.6.0" )
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 LinkedList ¶ added in v1.2.0
type LinkedList[K comparable, V any] struct { // contains filtered or unexported fields }
Example ¶
a := NewArena(1024*1024, 2) // 2MB arena size defer a.Release() l := NewLinkedList[string, string](a) l.Push("hello1", "world1") v, ok := l.Get("hello1") fmt.Println(v, ok) l.Push("hello2", "world2") v, ok = l.Get("hello2") fmt.Println(v, ok) l.Scan(func(key string, value string) bool { fmt.Println(key, value) return true }) l.Clear() _, ok = l.Get("hello1") fmt.Println(ok)
Output: world1 true world2 true hello2 world2 hello1 world1 false
func NewLinkedList ¶ added in v1.2.0
func NewLinkedList[K comparable, V any](arena Arena) *LinkedList[K, V]
func (*LinkedList[K, V]) Clear ¶ added in v1.2.0
func (l *LinkedList[K, V]) Clear()
func (*LinkedList[K, V]) Delete ¶ added in v1.2.0
func (l *LinkedList[K, V]) Delete(key K) (old V, found bool)
func (*LinkedList[K, V]) DeleteAll ¶ added in v1.3.0
func (l *LinkedList[K, V]) DeleteAll()
func (*LinkedList[K, V]) Get ¶ added in v1.2.0
func (l *LinkedList[K, V]) Get(key K) (old V, found bool)
func (*LinkedList[K, V]) Len ¶ added in v1.2.0
func (l *LinkedList[K, V]) Len() int
func (*LinkedList[K, V]) Push ¶ added in v1.2.0
func (l *LinkedList[K, V]) Push(key K, value V) (old V, found bool)
func (*LinkedList[K, V]) Scan ¶ added in v1.2.0
func (l *LinkedList[K, V]) Scan(iter func(K, V) bool)
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Example ¶
a := NewArena(1024*1024, 2) // 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(1024*1024, 2) // 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.