diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-05-25 00:45:51 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-05-25 00:45:51 -0400 |
commit | 8860413709853bf1daede5e2c95d502791952b7b (patch) | |
tree | 6596117aeeddfe9002ebf71c175c1e03b73a508f | |
parent | 7b4a46a736f47222937ba875c162591d50b08d72 (diff) |
Add push front for double ended queue.
-rw-r--r-- | collections/double_ended_queue.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index dac22b6..967a716 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -88,6 +88,20 @@ void *item; *(root->end++) = item; } +void deq_push_front(root, item) +deq *root; +void *item; +{ + if (!root) { + return; + } + if (root->end == root->base + root->limit) { + deq_resize(root); + } + + *(root->end++) = item; +} + void* deq_pop_front(root) deq *root; { |