diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-05-27 03:32:07 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-05-27 03:32:07 -0400 |
commit | ee17ff1921ea790125d0c4b804f3c78a1f4c0a34 (patch) | |
tree | 9cded87e416bbc4fcf96f59ddf920b7ff6630de7 | |
parent | c3f2eed02152d5902fa26a625d11207e64301849 (diff) |
Fix double ended queue pop front w/ wrap around.
-rw-r--r-- | collections/double_ended_queue.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index 8a6a91e..285983b 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -127,7 +127,10 @@ deq *root; return NULL; } - return tmp = *(root->beg++); + tmp = *(root->beg++); + root->beg = (root->base + (root->beg - root->base) % root->limit); + + return tmp; } void* deq_index(root, index) |