diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-06-10 12:55:33 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-06-10 12:55:33 -0400 |
commit | b38bcd56356973a50797630f8366d6701dd7c988 (patch) | |
tree | 8d1f819426d4d1a3417aca523798934740c25d37 | |
parent | ce6d7f43e7ad77b3eec043ff731d17ab21e89e87 (diff) |
Add set index function for double ended queue.
-rw-r--r-- | collections/double_ended_queue.c | 10 | ||||
-rw-r--r-- | collections/double_ended_queue.h | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index e737d28..232fb44 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -101,6 +101,16 @@ deq *root; root->base = tmp; } +void deq_set(root, index, item) +deq *root; +int index; +void *item; +{ + if (!root || !DEQ_IN_BOUNDS(root, index)) + return; + root->base[(root->beg + index) % root->limit] = item; +} + void* deq_index(root, index) deq *root; int index; diff --git a/collections/double_ended_queue.h b/collections/double_ended_queue.h index 877503d..332b16f 100644 --- a/collections/double_ended_queue.h +++ b/collections/double_ended_queue.h @@ -22,8 +22,9 @@ void deq_clear(); /*data*/ void deq_push_back(deq*, void*); void* deq_pop_front(deq*); -void* deq_index(deq*, int); void* deq_pop_back(deq*); +void deq_set(deq*, int, void*); +void* deq_index(deq*, int); void deq_swap(deq*, int, int); |