34#ifndef LIBAARUFORMAT_STATIC_LRU_HASH_MAP_H
35#define LIBAARUFORMAT_STATIC_LRU_HASH_MAP_H
46#ifndef STATIC_LRU_EVICTION_LOAD_FACTOR
47#define STATIC_LRU_EVICTION_LOAD_FACTOR 0.90
50#ifndef STATIC_LRU_TARGET_LOAD_FACTOR
51#define STATIC_LRU_TARGET_LOAD_FACTOR 0.75
54#ifndef STATIC_LRU_AGING_INTERVAL
55#define STATIC_LRU_AGING_INTERVAL 100000
58#ifndef STATIC_LRU_MIN_SIZE
59#define STATIC_LRU_MIN_SIZE 1024
108#ifdef STATIC_LRU_ENABLE_STATS
109 uint64_t total_lookups;
111 uint64_t total_inserts;
112 uint64_t eviction_count;
113 uint64_t eviction_cycles;
259#ifdef STATIC_LRU_ENABLE_STATS
void static_lru_free_map(static_lru_hash_map_t *map)
Frees all memory associated with a static LRU hash map.
void static_lru_age_counts(static_lru_hash_map_t *map)
Manually ages all access counts.
size_t static_lru_free_slots(const static_lru_hash_map_t *map)
Returns the number of free slots available.
static_lru_hash_map_t * static_lru_create_map(size_t size)
Creates a new static LRU hash map with fixed size.
size_t static_lru_evict(static_lru_hash_map_t *map, size_t entries_to_keep)
Manually triggers eviction of least-used entries.
bool static_lru_lookup_map(static_lru_hash_map_t *map, uint64_t key, uint64_t *out_value)
Looks up a value by key in the static LRU hash map.
double static_lru_load_factor(const static_lru_hash_map_t *map)
Returns the current load factor of the map.
bool static_lru_insert_map(static_lru_hash_map_t *map, uint64_t key, uint64_t value)
Inserts a key-value pair into the static LRU hash map.
bool static_lru_contains_key(const static_lru_hash_map_t *map, uint64_t key)
Checks if a key exists in the map WITHOUT updating access count.
Single key/value slot with access tracking for the static LRU hash map.
uint8_t access_count
Access frequency counter (0-255, saturates at 255).
uint8_t _padding[7]
Padding for 8-byte alignment (24 bytes total per entry).
uint64_t value
Associated value payload (64-bit).
uint64_t key
Stored key (64-bit). 0 indicates an empty slot.
Fixed-size hash map with LRU-like eviction for bounded memory usage.
size_t max_count
Eviction trigger threshold (size * EVICTION_LOAD_FACTOR).
uint32_t age_counter
Operations since last aging.
size_t target_count
Target count after eviction (size * TARGET_LOAD_FACTOR).
size_t count
Number of active (filled) entries.
lru_kv_pair_t * table
Array of key/value slots of length == size.
size_t size
Allocated slot capacity (FIXED at creation).
uint32_t _padding
Padding for alignment.