summaryrefslogtreecommitdiff
path: root/src/array.h
blob: 035e1ee4d0b30730d0dce01b035f1430fe6d6d49 (plain)
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
#pragma once
#include "memory/memory.h"
#include "entity.h"

struct EntityArr {
  struct Entity *buffer;
  unsigned int capacity;
  unsigned int size; // used for mantaining a stack and queue
};

typedef EntityArr EntityArrayList;

struct EntityArr entity_arr_init(struct Arena *arena, unsigned int size);

// -- basic insert remove operations --
void entity_arr_insert(struct EntityArr *arr, struct Entity to_insert, unsigned int index);
struct Entity entity_arr_remove(struct EntityArr *arr, struct Entity to_remove, unsigned int index);

void entity_arr_push_head(struct EntityArr *arr, struct Entity value);
void entity_arr_push_tail(struct EntityArr *arr, struct Entity value);

struct Entity entity_arr_pop_head(struct EntityArr *arr);
struct Entity entity_arr_pop_tail(struct EntityArr *arr);

typedef EntityArr EntityQueue;
void entity_qpush(EntityQueue *queue, struct Entity value);
struct Entity entity_qpop(EntityQueue *queue);

typedef EntityArr EntityStack;
void entity_spush(EntityStack *stack, struct Entity value);
struct Entity entity_spop(EntityStack *stack, struct Entity value);

// -- operations on values --
int entity_arr_find(struct EntityArr *arr, struct Entity value);