aboutsummaryrefslogtreecommitdiff
path: root/pa6_threaded_resolver/array.h
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2024-04-02 23:09:33 -0600
committerJack Sangdahl <[email protected]>2024-04-02 23:09:33 -0600
commit7ddf686201d052e7c55d622dddd62b7e2ede880d (patch)
tree1ce98638df78223b5a42ef8ba7aa7b1f5d49941a /pa6_threaded_resolver/array.h
parentf3172b837cc728dec1daa74ce98a72548f204b21 (diff)
downloadcsci3753-7ddf686201d052e7c55d622dddd62b7e2ede880d.tar.gz
csci3753-7ddf686201d052e7c55d622dddd62b7e2ede880d.zip
pa6
Diffstat (limited to 'pa6_threaded_resolver/array.h')
-rw-r--r--pa6_threaded_resolver/array.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/pa6_threaded_resolver/array.h b/pa6_threaded_resolver/array.h
new file mode 100644
index 0000000..adceca8
--- /dev/null
+++ b/pa6_threaded_resolver/array.h
@@ -0,0 +1,62 @@
+// Jack Sangdahl
+// CSCI3753 SP24
+// PA6 Threaded Resolver
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+typedef struct {
+ void *value;
+} node;
+
+typedef struct {
+ node *data;
+ int size;
+ int maxsize;
+ int front;
+ int back;
+} queue;
+
+/**
+ * @brief initialise the queue
+ * @param q
+ * @param size
+ * @return int
+ */
+int queue_init(queue *q, int size);
+
+/**
+ * @brief return size of queue
+ * @param q
+ * @return int
+ */
+int queue_size(queue *q);
+
+/**
+ * @brief return true if que size is
+ * greater than ARRAY_SIZE. false otherwise
+ * @param q
+ * @return bool
+ */
+bool queue_full(queue *q);
+
+/**
+ * @brief add element to fifo queue. block when full
+ * @param q
+ * @param val
+ * @return int
+ */
+int queue_push(queue *q, void *val);
+
+/**
+ * @brief return top element of queue in fifo order
+ * return null pointer if queue empty
+ * @param q
+ */
+void *queue_pop(queue *q);
+
+/**
+ * @brief free queue's resources
+ * @param q
+ */
+void queue_free(queue *q);