fmap

package
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2025 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
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.

View Source
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

func NewFastMap[T any](expectedSize int, fillFactor float64) *FastMap[T]

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]) Cap added in v0.4.0

func (m *FastMap[T]) Cap() int

Cap returns the computeCapacity of the map.

func (*FastMap[T]) Clear added in v0.4.0

func (m *FastMap[T]) Clear(expectedSize int, keys []int64, data []T)

func (*FastMap[T]) Get added in v0.4.0

func (m *FastMap[T]) Get(key int64) (T, bool)

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

func (m *FastMap[T]) GetPointer(key int64) (*T, bool)

GetPointer retrieves the value pointer associated with the given key. It returns the value and a boolean indicating whether the key was found.

func (*FastMap[T]) Iterator added in v0.4.1

func (m *FastMap[T]) Iterator() func() (int, T, bool)

func (*FastMap[T]) Put added in v0.4.0

func (m *FastMap[T]) Put(key int64, val T)

Put adds or updates the key with the value val.

func (*FastMap[T]) SCN added in v0.4.3

func (m *FastMap[T]) SCN() int

SCN returns the current sequence number of the map

func (*FastMap[T]) Size added in v0.4.0

func (m *FastMap[T]) Size() int

Size returns the number of elements in the map.

func (*FastMap[T]) Value added in v0.4.1

func (m *FastMap[T]) Value(ptr *int, foundFreeKey *bool) (k int, t T, hasMode bool)

Value returns the key and value at the given pointer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL