diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-02-23 14:09:26 -0500 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-02-23 15:00:17 -0500 |
commit | 995f7838c0d47b3f4974e8bf501daf1d1f5e247f (patch) | |
tree | c27d4a82784a52bbd7073409cacea6e7ab33dd98 /collections/double_ended_queue.c | |
parent | c38089c8246d25f64557de6cf2542b48f91ace4c (diff) |
Add truncate function for double ended queue
Diffstat (limited to 'collections/double_ended_queue.c')
-rw-r--r-- | collections/double_ended_queue.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index 6a3a810..1f18330 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -181,3 +181,14 @@ int i, j; root->end[j] = root->end[i]; root->end[i] = tmp; } + +void deq_truncate(root, size) +deq *root; +int size; +{ + if ((!root) || size > deq_size(root)) { + return; + } + + root->end = root->beg + size; +} |