We introduce a very simple queue implementation with the singly linked list. With the help of the rear sentinel instead of the traditional header node, we avoid additional check steps in the pop operation. The essence of this representation is the half-opened pointer interval, which can guarantee the uniform treatment even in the empty queue case. We also present the variants of linked queue, circularly linked queue and lazy circularly linked queue, which can also be used to implement stack and improve the time performance in some special cases.
翻译:我们引入一个使用单一链接列表的非常简单的队列执行。 在后端哨兵而不是传统页眉节点的帮助下, 我们避免在弹出操作中采取额外的检查步骤。 此表达式的精髓是半开放的指针间隔, 它可以保证即使在空队列的情况下也得到统一的处理 。 我们还展示了连接队列、 循环链接队列和懒惰的循环链接队列的变体, 这些变体也可以用来执行堆叠, 在某些特殊情况下可以改进时间性能 。