全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Queue, enqueue, dequeue, FIFO?

又称: queue · enqueue · dequeue · FIFO

Definition 24.4 High School Computer Science · 第 24 章 — Linked Lists, Stacks and Queues

A queue is an abstract data type holding a sequence, with the operations: create an empty queue; test whether it is empty; enqueue an element at the back; dequeue the element at the front, removing and returning it, refused on an empty queue. The first element enqueued is the first dequeued: the queue is FIFO, first in, first out.

A linked queue holding 5, 8, 2. Enqueueing 7 links a new cell after the tail and moves _tail to it (dashed); dequeueing moves _head to the next cell.
A linked queue holding 5,8,25, 8, 2. Enqueueing 77 links a new cell after the tail and moves _tail to it (dashed); dequeueing moves _head to the next cell.
A queue from two stacks. The transfer pops 3, 2, 1 from the in-stack and pushes them on the out-stack, where 1, the oldest, is now on top. The next two dequeues pop 2 and 3 with no transfer.
A queue from two stacks. The transfer pops 33, 22, 11 from the in-stack and pushes them on the out-stack, where 11, the oldest, is now on top. The next two dequeues pop 22 and 33 with no transfer.
在原文中阅读 →