list.h 719 Bytes
Newer Older
Jacob Vosmaer's avatar
Jacob Vosmaer committed
1 2 3
#ifndef _list_h
#define _list_h

4
#include <stdint.h>
Jacob Vosmaer's avatar
Jacob Vosmaer committed
5 6 7 8 9 10 11

struct list {
	uint8_t head;
	uint8_t *array;
	uint8_t sup;
};

12 13 14 15 16 17 18 19
#define INIT_LIST(name, size) \
	static uint8_t _ ## name ## _array[size]; \
	static struct list _ ## name = {\
		.array = _ ## name ## _array,\
		.sup = size,\
	};\
	static struct list *name = &_ ## name;

Jacob Vosmaer's avatar
Jacob Vosmaer committed
20
void l_push(struct list *l, uint8_t x);
21
void l_append(struct list *l, uint8_t x);
Jacob Vosmaer's avatar
Jacob Vosmaer committed
22
void l_delete(struct list *l, uint8_t x);
23
uint8_t l_first(struct list *l);
Jacob Vosmaer's avatar
Jacob Vosmaer committed
24 25
uint8_t l_last(struct list *l);
void l_flush(struct list *l);
26
uint8_t l_empty(struct list *l);
27
uint8_t l_contains(struct list *l, uint8_t x);
28 29
uint8_t l_succ(struct list *l, uint8_t x);
uint8_t l_index(struct list *l, uint8_t x);
Jacob Vosmaer's avatar
Jacob Vosmaer committed
30 31

#endif