Documentation
¶
Overview ¶
Example ¶
alloc := batchallocator.New(allocator.NewC())
defer alloc.Destroy()
hm := New[int, int](alloc)
defer hm.Free() // can be removed
hm.Set(1, 10)
hm.Set(2, 20)
hm.Set(3, 30)
sumKeys := 0
sumValues := 0
for k, v := range hm.Iter() {
sumKeys += k
sumValues += v
}
fmt.Println(sumKeys)
fmt.Println(sumValues)
Output: 6 60
Index ¶
- type Hashmap
- func (hm *Hashmap[K, V]) Delete(key K)
- func (hm *Hashmap[K, V]) Free()
- func (hm *Hashmap[K, V]) Get(key K) (value V, exists bool)
- func (hm *Hashmap[K, V]) GetPtr(key K) (value *V, exists bool)
- func (hm *Hashmap[K, V]) Iter() iter.Seq2[K, V]
- func (hm *Hashmap[K, V]) Keys() []K
- func (hm *Hashmap[K, V]) Set(key K, value V)
- func (hm *Hashmap[K, V]) Values() []V
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hashmap ¶
type Hashmap[K comparable, V any] struct { // contains filtered or unexported fields }
Hashmap Manually managed hashmap,
func New ¶
func New[K comparable, V any](alloc allocator.Allocator) *Hashmap[K, V]
New creates a new Hashmap with key of type K and value of type V
func (*Hashmap[K, V]) Delete ¶ added in v0.7.0
func (hm *Hashmap[K, V]) Delete(key K)
Delete delete value with key K
func (*Hashmap[K, V]) Keys ¶ added in v0.7.0
func (hm *Hashmap[K, V]) Keys() []K
Keys returns all keys as a slice
Click to show internal directories.
Click to hide internal directories.