diff options
-rw-r--r-- | collections/double_ended_queue.c | 11 | ||||
-rw-r--r-- | collections/double_ended_queue.h | 2 |
2 files changed, 12 insertions, 1 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; +} diff --git a/collections/double_ended_queue.h b/collections/double_ended_queue.h index d1d687a..283d9c3 100644 --- a/collections/double_ended_queue.h +++ b/collections/double_ended_queue.h @@ -20,11 +20,11 @@ void* deq_index(deq*, int); void* deq_pop_back(deq*); void deq_swap(deq*, int, int); +void deq_truncate(deq*, int); /* * resevee - * truncate * front * back * push/pop front |