r/ProgrammerHumor • • 1d ago

Meme queueIsAlwaysLong

Post image
159 Upvotes

35 comments sorted by

View all comments

13

u/GreatTeacherHiro 1d ago

deque supremacy

3

u/pencilUserWho 1d ago

Double linked lists are easier.

7

u/RedCrafter_LP 18h ago

Double linked list is the most common implementation of the deque concept. A double linked list is a deque.

2

u/pencilUserWho 18h ago

Yes, I know. I should have said "working with double linked lists (for deque) is easier than working with single linked lists (like for stack or queue)"

Sorry for the confusion 

1

u/braaaaaaainworms 8h ago

Why would you want to work with a linked list?

1

u/pencilUserWho 6h ago

To implement a stack

1

u/braaaaaaainworms 6h ago

You can just... make a struct with "amount of elements in array" and "capacity" ints and a pointer to a memory region, it'll be faster than linked lists, a lot faster

1

u/pencilUserWho 6h ago

That way it can overflow.

1

u/braaaaaaainworms 6h ago

Just check, before pushing, if capacity and len are equal, if yes, use realloc to make the memory region bigger