Documentation ¶
Index ¶
- Constants
- type HashMap
- func (m *HashMap[K, V]) Del(key K)
- func (m *HashMap[K, V]) Fillrate() uintptr
- func (m *HashMap[K, V]) ForEach(lambda func(K, V))
- func (m *HashMap[K, V]) Get(key K) (value V, ok bool)
- func (m *HashMap[K, V]) Grow(newSize uintptr)
- func (m *HashMap[K, V]) Len() uintptr
- func (m *HashMap[K, V]) Set(key K, value V)
- type List
- type ListElement
Constants ¶
const ( // DefaultSize is the default size for a zero allocated map DefaultSize = 8 // MaxFillRate is the maximum fill rate for the slice before a resize will happen. MaxFillRate = 50 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashMap ¶
type HashMap[K hashable, V any] struct { Hasher func(K) uintptr // contains filtered or unexported fields }
HashMap implements a read optimized hash map.
func (*HashMap[K, V]) Fillrate ¶
func (m *HashMap[K, V]) Fillrate() uintptr
Fillrate returns the fill rate of the map as an percentage integer.
func (*HashMap[K, V]) ForEach ¶
func (m *HashMap[K, V]) ForEach(lambda func(K, V))
ForEach iterates over key-value pairs and executes the lambda provided for each such pair.
func (*HashMap[K, V]) Get ¶
func (m *HashMap[K, V]) Get(key K) (value V, ok bool)
Get retrieves an element from the map under given hash key. Using interface{} adds a performance penalty. Please consider using GetUintKey or GetStringKey instead.
func (*HashMap[K, V]) Grow ¶
func (m *HashMap[K, V]) Grow(newSize uintptr)
Grow resizes the hashmap to a new size, gets rounded up to next power of 2. To double the size of the hashmap use newSize 0. This function returns immediately, the resize operation is done in a goroutine. No resizing is done in case of another resize operation already being in progress.
func (*HashMap[K, V]) Len ¶
func (m *HashMap[K, V]) Len() uintptr
Len returns the number of key-value pairs within the map.
func (*HashMap[K, V]) Set ¶
func (m *HashMap[K, V]) Set(key K, value V)
Set sets the value under the specified key to the map. An existing item for this key will be overwritten. If a resizing operation is happening concurrently while calling Set, the item might show up in the map only after the resize operation is finished.
type List ¶
type List[K hashable, V any] struct { // contains filtered or unexported fields }
List is a sorted doubly linked list.
func (*List[K, V]) AddOrUpdate ¶
func (l *List[K, V]) AddOrUpdate(element *ListElement[K, V], searchStart *ListElement[K, V]) bool
AddOrUpdate adds or updates an item to the list.
func (*List[K, V]) Delete ¶
func (l *List[K, V]) Delete(element *ListElement[K, V])
Delete deletes an element from the list.
func (*List[K, V]) First ¶
func (l *List[K, V]) First() *ListElement[K, V]
First returns the first item of the list.
type ListElement ¶
type ListElement[K hashable, V any] struct { // contains filtered or unexported fields }
ListElement is an element of a list.
func (*ListElement[K, V]) Next ¶
func (e *ListElement[K, V]) Next() *ListElement[K, V]
Next returns the item on the right.
func (*ListElement[K, V]) Previous ¶
func (e *ListElement[K, V]) Previous() *ListElement[K, V]
Previous returns the item on the left.
func (*ListElement[K, V]) Value ¶
func (e *ListElement[K, V]) Value() (value V)
Value returns the value of the list item.