diff options
Diffstat (limited to 'collections/double_ended_queue.c')
-rw-r--r-- | collections/double_ended_queue.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index ee93196..6a3a810 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -159,3 +159,25 @@ deq *root; copy->beg = copy->base; copy->end = copy->base + deq_size(root); } + +void deq_swap(root, i, j) +deq *root; +int i, j; +{ + int len; + void *tmp; + + if (!root) { + return; + } + + len = deq_size(root); + + if (i >= len || j >= len) { + return; + } + + tmp = root->end[i]; + root->end[j] = root->end[i]; + root->end[i] = tmp; +} |