diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-02-23 14:21:16 -0500 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-02-23 15:00:17 -0500 |
commit | 25395399f6a2822042a445fd6c812566d36dc3f9 (patch) | |
tree | 24fc942aaec0d493f01774f41b7199744f071c13 | |
parent | 995f7838c0d47b3f4974e8bf501daf1d1f5e247f (diff) |
Add front/back access functions for double ended queue
-rw-r--r-- | collections/double_ended_queue.c | 20 | ||||
-rw-r--r-- | collections/double_ended_queue.h | 8 |
2 files changed, 24 insertions, 4 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index 1f18330..ac9c131 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -192,3 +192,23 @@ int size; root->end = root->beg + size; } + +void* deq_front(root) +deq *root; +{ + if (!root) { + return; + } + + return *root->beg; +} + +void* deq_back(root) +deq *root; +{ + if (!root) { + return; + } + + return *root->end; +} diff --git a/collections/double_ended_queue.h b/collections/double_ended_queue.h index 283d9c3..226918d 100644 --- a/collections/double_ended_queue.h +++ b/collections/double_ended_queue.h @@ -22,13 +22,13 @@ void* deq_pop_back(deq*); void deq_swap(deq*, int, int); void deq_truncate(deq*, int); +void* deq_front(deq*); +void* deq_back(deq*); + /* * resevee - * front - * back - * push/pop front - * push/pop back + * push back * swap_rm_front/back * insert * remove |