That should not be a question

排队还是不排队?Waiting In Line To See Star Wars: 1977–2000

ño one likes to stand in line¹. Most people hate to waste their time queuing up. We spend an average of 6 months of our adult lives waiting our turn — almost 3 days a year. There are books about queues. Documentaries². Even academic experts in queues. But then, when we are coding, we often forget to use queues and end up messing around with lists instead.

当您使用正确的工具时,一切都会更好。

FIFO or LIFO1!!!

A queue in a supermarket is FIFO. The way we usually stack boxes is LIFO. FIFO stands for “First In, First Out”³. LIFO is the acronym for “Last In, First Out”. That’s it.

排队还是不排队?
I used draw.io to draw this diagram. Awesome tool!

实施时先进先出我们通常使用的队列加,窥视 (returns,but does not remove,the head of the queue)和轮询 (returns和removes the head of the queue) methods,while we refer to them,respectively,as 推,窥视和流行音乐在** LIFO **堆栈中。

The STACK, the QUEUE and the DEQUE

在一个堆我们只能从一端添加和删除元素(生命力), 在一个队列我们将元素添加到一端并将其从另一端删除(先进先出),然后加入这两个世界,双端队列(又名“双端队列”),我们可以在两端添加和删除元素。它们都不允许随机访问元素。



In JAVA you should use deque to model a stack because the Stack class is considered obsolete (it extends the Vector class and inherits all its methods, making it possible to break the LIFO principle).

So, don’t reinvent the wheel⁴.

This article was originally published on Medium


[1] Ok, there are some weird exceptions:facepalm:
[2] There is always an alternative https://www.youtube.com/watch?v=ZyNz8UHHrxE (in Spanish)????
[3] Some people know it as FCFS (“First Come, First Served”)
[4] And remember to give LolaMarket a chance. Awesome service!


Ëxternal links ????

from: https://dev.to//hector6872/to-queue-or-not-to-queue-4d2a

相关文章: