Hacker News new | ask | show | jobs
by orlp 47 days ago
> If you push, then pop, you should have the same data as you started with.

That's the case for a LIFO queue, but not a FIFO queue. Both commonly use the push/pop nomenclature.

2 comments

I would say that's not common but in fact I don't think I've ever seen both push() & pop() be used to refer to those operations on FIFO queues in any language. (And LIFO is a stack, the exact opposite of a queue.)

The terminology I've seen people use for FIFO instead is enqueue() and dequeue(). Or push_front(), pop_back(). Etc.

Ah I haven't seen that before. I must admit that I'm not in the literature side of things. Any time I've seen a queue in production it would use put/get or enqueue/dequeue and in Ruby scripts you'd use an array and use push/shift.