r/ProgrammerHumor • • 11d ago

Meme queueIsAlwaysLong

Post image
242 Upvotes

48 comments sorted by

179

u/PsychologicalNet3455 11d ago

That's easy, in the USA you use a stack and in the UK you use a queue.  

The stack because you need a stack of money for anything medical in the US and the queue for the UK, while its free, you have to join a long queue before anything medical happens

16

u/LoyalSol 11d ago

I feel like the question on which to use is a pop quiz.

9

u/ceejayoz 11d ago

Oh we're doing the long queue thing here in the States too.

7

u/knightress_oxhide 11d ago

The USA would be a queue of stacks. You still have to join a long queue.

2

u/a-r-c 10d ago

america is both these days

1

u/just_nobodys_opinion 4d ago

Whether you're in a stack or a queue, you know you're in a whole heap of trouble

83

u/rover_G 11d ago

Maybe a priority queue?

22

u/LoveOfSpreadsheets 11d ago

[Drake no] Priority

[Drake yes] Triage

11

u/Afraid-Locksmith6566 11d ago

priority stack

1

u/DeepGas4538 10d ago

yeah, it's never a first come first serve

1

u/lmarcantonio 7d ago

…triage is actually tagging people with colours, so yes

22

u/PseudoFrequency 10d ago

FIFO or LIFO. Simple.

5

u/a-r-c 10d ago

FAFO or YOLO. Simple.

3

u/Blue_Moon_Lake 10d ago

But what about priority boarding?

16

u/null_reference_user 10d ago

I just use an endless void:

  • adding an element to the void is always an immediate operation
  • removing an element is always an immediate operation
  • the void uses O(1) memory
  • the void is always empty

1

u/asato977424 3d ago

Zero latency, zero throughput: finally, a benchmark chart that looks perfect until you read the axes.

8

u/PostHasBeenWatched 11d ago

Integer Vector (IV)

6

u/Logicalist 11d ago

have you considered a jengaTower?

6

u/Norse_By_North_West 10d ago

Have you asked on queue overflow?

15

u/GreatTeacherHiro 11d ago

deque supremacy

3

u/pencilUserWho 11d ago

Double linked lists are easier.

8

u/RedCrafter_LP 10d ago

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

2

u/pencilUserWho 10d 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 10d ago

Why would you want to work with a linked list?

1

u/pencilUserWho 10d ago

To implement a stack

1

u/braaaaaaainworms 10d 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 10d ago

That way it can overflow.

1

u/braaaaaaainworms 10d ago

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

1

u/Nightmoon26 10d ago

This is how some libraries probably implement it by default. But in cases where memory efficiency is critical, the structure might get arbitrarily large, and/or the size of the of the structure may vary dramatically and non-monotonically over its lifetime, linked lists avoid overallocation and the intermittent performance hitches of reallocate-and-copy operations. Also, so long as you only ever need to do operations to the end, linked lists are simpler to implement and reason about (less chance of off-by one errors or other gotchas, and you don't need to wrap your head around amortization to see the O(1) time complexity for push/pop operations)

That mandatory Algorithms class in computer science programs is in part about being able to tell when you can and should deviate from the default way of doing things

→ More replies

1

u/d3matt 6d ago

Not particularly. Most deque implementations use heap allocated arrays for the underlying storage.

1

u/EatingSolidBricks 6d ago

No. It is

T* data

int head

int tail

1

u/EatingSolidBricks 6d ago

🤢 memory indirection

5

u/Hottage 10d ago

I use a stack... of bodies. My software isn't very good.

4

u/snipsuper415 11d ago

Use a deque

2

u/mr_nonameuser 11d ago

Use a linked list

1

u/h4rdw00d_ 10d ago

A triage is a queue...what to use...

1

u/Robot_Graffiti 10d ago

I've actually worked on medical software, and we used a fuckload of dictionaries, not many queues or stacks. The data's all stuff you could reasonably store in a relational database. Dictionaries in memory mirror the functionality of database indexes on disc.

1

u/CryonautX 10d ago

Surely a priority queue is the answer

1

u/The_Cosmin 10d ago

Use a set so that there can't be 2 instances of the same human

1

u/Nightmoon26 10d ago

You need to be careful about how you define sameness... People tend to get upset if you accidentally drop an identical twin/triplet/etc. and they get garbage collected

1

u/Rough-Supermarket-97 10d ago

How about a stacked queue?

1

u/StoryAndAHalf 9d ago

Before modern medicine, doctors/barbers used a queue first, and a stack later!

1

u/Pixel1101 6d ago

I mean, theoretically it could be impossible for something at the bottom of the stack to be processed

1

u/santient 4d ago

Quack