diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-06-08 22:25:24 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-06-08 22:25:24 -0400 |
commit | f4ce6540cfaf754ab4f0a6d4b8ed6b38c0cbe956 (patch) | |
tree | b46755efd625ef1f3932794bf1f663037ead273e | |
parent | 7e3a4d7bd009df8975f5ef374f979da7405fd501 (diff) |
Add double ended queue swap remove front/back functions.
-rw-r--r-- | collections/double_ended_queue.c | 16 | ||||
-rw-r--r-- | collections/double_ended_queue.h | 5 |
2 files changed, 19 insertions, 2 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index a8daf92..169693d 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -184,6 +184,22 @@ deq *root; return root->base[root->end]; } +void* deq_swap_rm_front(root, index) +deq *root; +int index; +{ + deq_swap(root, 0, index); + return deq_pop_front(root); +} + +void* deq_swap_rm_back(root, index) +deq *root; +int index; +{ + deq_swap(root,deq_size(root) - 1,index); + return deq_pop_back(root); +} + void deq_remove(root, index) deq *root; int index; diff --git a/collections/double_ended_queue.h b/collections/double_ended_queue.h index b708624..877503d 100644 --- a/collections/double_ended_queue.h +++ b/collections/double_ended_queue.h @@ -27,6 +27,9 @@ void* deq_pop_back(deq*); void deq_swap(deq*, int, int); +void* deq_swap_rm_front(deq*, int); +void* deq_swap_rm_back(deq*, int); + /*Note: Does not currently reduce memory footprint*/ void deq_truncate(deq*, int); @@ -38,8 +41,6 @@ void deq_remove(deq*, int); /* * resevee - * push back - * swap_rm_front/back * insert */ #endif |