-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBufferMap.h
More file actions
47 lines (40 loc) · 1.4 KB
/
BufferMap.h
File metadata and controls
47 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <Util/EngineTypes.h>
typedef void (*System_PoolAllocator_OnFreeDelegate)(void* data);
struct PoolAllocator
{
void* Data;
void* RawData;
u32* FreeList;
u64 FreeCount;
u64 FreeCapacity;
u64 Count;
u64 capacity;
u32 DataSize;
u32 Alignment;
};
void Systems_PoolAllocator_Init(PoolAllocator* Allocator, u64 InitialCapacity, u32 DataSize, u32 Alignment = 1);
void Systems_PoolAllocator_Free(PoolAllocator* Allocator, System_PoolAllocator_OnFreeDelegate OnFreeDelegate);
u32 Systems_PoolAllocator_PushData(PoolAllocator* Allocator, const void* Data);
void Systems_PoolAllocator_GetData(PoolAllocator* Allocator, u32 Index, void* OutData);
void Systems_PoolAllocator_FreeData(PoolAllocator* Allocator, u32 Index);
struct SparceHashMap
{
u64* Keys;
u32* Indices;
u8* ProbeDist;
u8* Occupied;
u64 Capacity;
u64 Count;
};
void Systems_SparceHashMap_Init(SparceHashMap* Map, u64 InitialCapacity);
void Systems_SparceHashMap_Free(SparceHashMap* Map);
void Systems_SparceHashMap_Insert(SparceHashMap* Map, u64 Key, u32 Index);
bool Systems_SparceHashMap_Get(const SparceHashMap* Map, u64 Key, u32* OutIndex);
bool Systems_SparceHashMap_Remove(SparceHashMap* Map, u64 Key, u32* OutIndex);