aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tucker@tuckerevans.com>2020-05-27 03:34:37 -0400
committerTucker Evans <tucker@tuckerevans.com>2020-05-27 03:34:37 -0400
commit0b8aa4ce92c042eabb3ebed94674aa6dc099a23c (patch)
treebdb3c1467b4a359494e905651334cab4d1f15822
parentee17ff1921ea790125d0c4b804f3c78a1f4c0a34 (diff)
Fix move index function for double ended queue.
-rw-r--r--collections/double_ended_queue.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c
index 285983b..25167e3 100644
--- a/collections/double_ended_queue.c
+++ b/collections/double_ended_queue.c
@@ -83,6 +83,24 @@ deq *root;
}
}
+void* deq_index(root, index)
+deq *root;
+int index;
+{
+ void *tmp;
+
+ if (!root) {
+ return NULL;
+ }
+
+ tmp = root->base + (root->beg + index - root->base) % root->limit);
+ if (tmp > root->end) {
+ return NULL;
+ }
+
+ return *tmp;
+}
+
void deq_push_back(root, item)
deq *root;
void *item;
@@ -133,24 +151,6 @@ deq *root;
return tmp;
}
-void* deq_index(root, index)
-deq *root;
-int index;
-{
- void *tmp;
-
- if (!root) {
- return NULL;
- }
-
- tmp = root->base + (root->beg + index - root->base) % root->limit);
- if (tmp > root->end) {
- return NULL;
- }
-
- return *tmp;
-}
-
void* deq_pop_back(root)
deq *root;
{