diff options
-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 |