aboutsummaryrefslogtreecommitdiff
path: root/include/lib/queue.h
blob: 1d4899ab0e7c0f2d5e3b83858e05b48fcc88f80f (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
#ifndef LIB_QUEUE_H
#define LIB_QUEUE_H

enum EntryType {
	VALUE_ENTRY = 0,
	START_ENTRY = 1,
	END_ENTRY = 2,
};

struct Entry {
	void* value;
	struct Entry* next;
	unsigned long entry_type;
};

struct Queue {
	struct Entry start;
	struct Entry end;
};

// Add to end of queue
void push_to_queue(struct Entry* e, struct Queue* q);
// Add to beginning of queue
void prepend_to_queue(struct Entry* e, struct Queue* q);
// Remove from beginning of queue
struct Entry* pop_from_queue(struct Queue* q);
// Remove the entry after this one from its queue
struct Entry* remove_next_from_queue(struct Entry* e);
// Find an entry in a queue
//  Returns the entry before the target entry
struct Entry* find_value(void* value, struct Queue* q);

#endif