aboutsummaryrefslogtreecommitdiff
path: root/collections/double_ended_queue.c
diff options
context:
space:
mode:
authorTucker Evans <tucker@tuckerevans.com>2020-06-10 12:55:33 -0400
committerTucker Evans <tucker@tuckerevans.com>2020-06-10 12:55:33 -0400
commitb38bcd56356973a50797630f8366d6701dd7c988 (patch)
tree8d1f819426d4d1a3417aca523798934740c25d37 /collections/double_ended_queue.c
parentce6d7f43e7ad77b3eec043ff731d17ab21e89e87 (diff)
Add set index function for double ended queue.
Diffstat (limited to 'collections/double_ended_queue.c')
-rw-r--r--collections/double_ended_queue.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c
index e737d28..232fb44 100644
--- a/collections/double_ended_queue.c
+++ b/collections/double_ended_queue.c
@@ -101,6 +101,16 @@ deq *root;
root->base = tmp;
}
+void deq_set(root, index, item)
+deq *root;
+int index;
+void *item;
+{
+ if (!root || !DEQ_IN_BOUNDS(root, index))
+ return;
+ root->base[(root->beg + index) % root->limit] = item;
+}
+
void* deq_index(root, index)
deq *root;
int index;