aboutsummaryrefslogtreecommitdiff
path: root/include/lib
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-03-18 12:57:53 -0700
committerChristian Cunningham <cc@localhost>2022-03-18 12:57:53 -0700
commit94f2b0b8f48f5715975446c637a078008fb7e941 (patch)
tree2fb1744748e3bd4c93b2dae65a6033763c17e737 /include/lib
parent7ea4a4e970ae4a72ac7b58e98d232662d580ed47 (diff)
Generalized Queue
Diffstat (limited to 'include/lib')
-rw-r--r--include/lib/queue.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/lib/queue.h b/include/lib/queue.h
new file mode 100644
index 0000000..5e57613
--- /dev/null
+++ b/include/lib/queue.h
@@ -0,0 +1,32 @@
+#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
+struct Entry* find_value(void* value, struct Queue* q);
+
+#endif