Skip to content

Instantly share code, notes, and snippets.

View akmalm07's full-sized avatar
🎯
Focusing

Akmal Mukhamadiev akmalm07

🎯
Focusing
View GitHub Profile
@akmalm07
akmalm07 / compact_map.h
Created January 25, 2026 00:37
This is a cache-friendly, vector-backed associative map for C++ optimized for fast iteration over small to medium datasets. Benchmarks show it achieves over 9× faster iteration than std::unordered_map, while unordered_map remains faster for random key lookups.
#pragma once
/*
compact_map — a cache-friendly vector-backed map for C++.
Benchmark results (10,000 integer keys):
| Operation | compact_map | unordered_map |
|------------|-------------------:|-----------------:|
| Lookup | 1,969,399 ns (~508 op/s) | 381,418 ns (~2,622 op/s) |