Documentation
¶
Index ¶
- Constants
- type HashMap
- func (m *HashMap) Cas(hashedKey uint64, from, to unsafe.Pointer) bool
- func (m *HashMap) Del(key interface{})
- func (m *HashMap) DelHashedKey(hashedKey uint64)
- func (m *HashMap) Fillrate() uint64
- func (m *HashMap) Get(key interface{}) (unsafe.Pointer, bool)
- func (m *HashMap) GetHashedKey(hashedKey uint64) (unsafe.Pointer, bool)
- func (m *HashMap) GetStringKey(key string) (unsafe.Pointer, bool)
- func (m *HashMap) GetUintKey(key uint64) (unsafe.Pointer, bool)
- func (m *HashMap) Grow(newSize uint64)
- func (m *HashMap) Iter() <-chan KeyValue
- func (m *HashMap) Len() uint64
- func (m *HashMap) Set(key interface{}, value unsafe.Pointer)
- func (m *HashMap) SetHashedKey(hashedKey uint64, value unsafe.Pointer)
- func (m *HashMap) String() string
- type KeyValue
- type List
- type ListElement
Constants ¶
const MaxFillRate = 50
MaxFillRate is the maximum fill rate for the slice before a resize will happen.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashMap ¶
type HashMap struct {
sync.Mutex // mutex that is only used for resize operations
// contains filtered or unexported fields
}
HashMap implements a read optimized hash map.
func (*HashMap) Del ¶
func (m *HashMap) Del(key interface{})
Del deletes the hashed key from the map.
func (*HashMap) DelHashedKey ¶
DelHashedKey deletes the hashed key from the map.
func (*HashMap) Get ¶
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) GetHashedKey ¶
GetHashedKey retrieves an element from the map under given hashed key.
func (*HashMap) GetStringKey ¶
GetStringKey retrieves an element from the map under given string key.
func (*HashMap) GetUintKey ¶
GetUintKey retrieves an element from the map under given integer key.
func (*HashMap) Grow ¶
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.
func (*HashMap) Iter ¶
Iter returns an iterator which could be used in a for range loop. The order of the items is sorted by hash keys.
func (*HashMap) Set ¶
Set sets the value under the specified hash 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.
func (*HashMap) SetHashedKey ¶
SetHashedKey sets the value under the specified hash key to the map. An existing item for this key will be overwritten. You can use this function if your keys are already hashes and you want to avoid another hashing of the key. Do not use non hashes as keys for this function, the performance would decrease! 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 struct {
// contains filtered or unexported fields
}
List is a sorted list.
func (*List) Add ¶
func (l *List) Add(newElement *ListElement, searchStart *ListElement) bool
Add adds or updates an item to the list.
func (*List) Cas ¶
func (l *List) Cas(newElement *ListElement, oldValue unsafe.Pointer, searchStart *ListElement) bool
Cas compares and swaps the values and add an item to the list.
func (*List) Delete ¶
func (l *List) Delete(element *ListElement)
Delete marks the list element as deleted.
type ListElement ¶
type ListElement struct {
// contains filtered or unexported fields
}
ListElement is an element of the list.
func (*ListElement) CasValue ¶
func (e *ListElement) CasValue(from, to unsafe.Pointer) bool
CasValue compares and swaps the values of the item.
func (*ListElement) Deleted ¶
func (e *ListElement) Deleted() bool
Deleted returns whether the item was deleted.
func (*ListElement) Next ¶
func (e *ListElement) Next() *ListElement
Next returns the item on the right.
func (*ListElement) SetDeleted ¶
func (e *ListElement) SetDeleted(deleted bool) bool
SetDeleted sets the deleted flag of the item.
func (*ListElement) SetValue ¶
func (e *ListElement) SetValue(value unsafe.Pointer)
SetValue sets the value of the item.
func (*ListElement) Value ¶
func (e *ListElement) Value() unsafe.Pointer
Value returns the value of the list item.