Skip to content

Instantly share code, notes, and snippets.

View hodgman's full-sized avatar

Hodgman hodgman

View GitHub Profile
@hodgman
hodgman / alloc.h
Created March 8, 2024 08:45
"arenas"
#include <type_traits>
#include <memory>
#include <cstdint>
// Simple arena implementation. A linked-list of large stacks of bytes
class Allocator
{
public:
Allocator() { Clear(); }
### Keybase proof
I hereby claim:
* I am hodgman on github.
* I am hodgman (https://keybase.io/hodgman) on keybase.
* I have a public key ASD8s5F5jUhkVA9lEgas77I0NwA2cdHb1tNfrK8s1WCb0Ao
To claim this, I am signing this object:
@hodgman
hodgman / lock free hash map.cpp
Created March 9, 2023 11:37
simple hash map due to constraints (no resize, no remove)
class HashMap {
constexpr NumBuckets = Length * Factor;
struct N {
K key;
N* next;
};
N nodes[Length];
V values[Length];
N* freeList;
N* buckets[NumBuckets];