Documentation
¶
Index ¶
- Constants
- type FastMap
- func (m *FastMap[T]) Cap() int
- func (m *FastMap[T]) Clear(expectedSize int, keys []int64, data []T)
- func (m *FastMap[T]) Get(key int64) (T, bool)
- func (m *FastMap[T]) GetPointer(key int64) (*T, bool)
- func (m *FastMap[T]) Iterator() func() (int, T, bool)
- func (m *FastMap[T]) Put(key int64, val T)
- func (m *FastMap[T]) SCN() int
- func (m *FastMap[T]) Size() int
- func (m *FastMap[T]) Value(ptr *int, foundFreeKey *bool) (k int, t T, hasMode bool)
Constants ¶
const FREE_KEY int64 = 0
FREE_KEY represents the zero value of int64 and is used to denote an empty slot in the keys array.
const INT_PHI = 0x9E3779B9
INT_PHI is a constant used in the hash function to scramble the keys. It is derived from the golden ratio and helps in distributing keys uniformly.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FastMap ¶ added in v0.4.0
type FastMap[T any] struct { // contains filtered or unexported fields }
FastMap is a high-performance hash map for int64 keys and numeric values. It uses open addressing with linear probing and a custom hash function for int64 keys. The map is generic over the value type T, which must satisfy the Numeric interface. This implementation is optimized for performance and low memory overhead, and is not safe for concurrent use.
func NewFastMap ¶ added in v0.4.0
NewNumericMap creates a new FastMap with the specified expected size and fill factor. The fill factor must be between 0 and 1 (exclusive), and determines when the map will be resized. The map will grow automatically as needed.
func (*FastMap[T]) Get ¶ added in v0.4.0
Get retrieves the value associated with the given key. It returns the value and a boolean indicating whether the key was found.
func (*FastMap[T]) GetPointer ¶ added in v0.4.0
GetPointer retrieves the value pointer associated with the given key. It returns the value and a boolean indicating whether the key was found.