Documentation ¶
Index ¶
- Constants
- type HashMap
- func (m *HashMap) Cas(key interface{}, from, to unsafe.Pointer) bool
- func (m *HashMap) CasHashedKey(hashedKey uintptr, from, to unsafe.Pointer) bool
- func (m *HashMap) Del(key interface{})
- func (m *HashMap) DelHashedKey(hashedKey uintptr)
- func (m *HashMap) Fillrate() uintptr
- func (m *HashMap) Get(key interface{}) (value unsafe.Pointer, ok bool)
- func (m *HashMap) GetHashedKey(hashedKey uintptr) (value unsafe.Pointer, ok bool)
- func (m *HashMap) GetOrInsert(key interface{}, value unsafe.Pointer) (actual unsafe.Pointer, loaded bool)
- func (m *HashMap) GetStringKey(key string) (value unsafe.Pointer, ok bool)
- func (m *HashMap) GetUintKey(key uintptr) (value unsafe.Pointer, ok bool)
- func (m *HashMap) Grow(newSize uintptr)
- func (m *HashMap) Insert(key interface{}, value unsafe.Pointer) bool
- func (m *HashMap) Iter() <-chan KeyValue
- func (m *HashMap) Len() int
- func (m *HashMap) Set(key interface{}, value unsafe.Pointer)
- func (m *HashMap) SetHashedKey(hashedKey uintptr, value unsafe.Pointer)
- func (m *HashMap) String() string
- type KeyValue
- type List
- func (l *List) Add(element *ListElement, searchStart *ListElement) (existed bool, inserted bool)
- func (l *List) AddOrUpdate(element *ListElement, searchStart *ListElement) bool
- func (l *List) Cas(element *ListElement, oldValue unsafe.Pointer, searchStart *ListElement) bool
- func (l *List) Delete(element *ListElement)
- func (l *List) First() *ListElement
- func (l *List) Len() int
- type ListElement
Constants ¶
const DefaultSize = 8
DefaultSize is the default size for a zero allocated map
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 {
// contains filtered or unexported fields
}
HashMap implements a read optimized hash map.
func (*HashMap) Cas ¶
Cas performs a compare and swap operation sets the value under the specified hash key to the map. An existing item for this key will be overwritten.
func (*HashMap) CasHashedKey ¶
CasHashedKey performs a compare and swap operation sets the value under the specified hash key to the map. An existing item for this key will be overwritten.
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) GetOrInsert ¶
func (m *HashMap) GetOrInsert(key interface{}, value unsafe.Pointer) (actual unsafe.Pointer, loaded bool)
GetOrInsert returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
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. 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) Insert ¶
Insert sets the value under the specified key to the map if it does not exist yet. 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. Returns true if the item was inserted or false if it existed.
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 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 doubly linked list.
func (*List) Add ¶
func (l *List) Add(element *ListElement, searchStart *ListElement) (existed bool, inserted bool)
Add adds an item to the list and returns false if an item for the hash existed.
func (*List) AddOrUpdate ¶
func (l *List) AddOrUpdate(element *ListElement, searchStart *ListElement) bool
AddOrUpdate adds or updates an item to the list.
func (*List) Cas ¶
func (l *List) Cas(element *ListElement, oldValue unsafe.Pointer, searchStart *ListElement) bool
Cas compares and swaps the value of an item in 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 a list.
func (*ListElement) CasValue ¶
func (e *ListElement) CasValue(from, to unsafe.Pointer) bool
CasValue compares and swaps the values of the item.
func (*ListElement) Next ¶
func (e *ListElement) Next() *ListElement
Next returns the item on the right.
func (*ListElement) Previous ¶
func (e *ListElement) Previous() *ListElement
Previous returns the item on the left.
func (*ListElement) SetValue ¶
func (e *ListElement) SetValue(value unsafe.Pointer)
SetValue sets the value of the item.
func (*ListElement) Value ¶
func (e *ListElement) Value() (value unsafe.Pointer)
Value returns the value of the list item.