Java中的快速队列 [英] A fast queue in Java

查看:126
本文介绍了Java中的快速队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找Java中的快速队列实现。我看到 LinkedList 实现了 Queue 接口,但它只能与一样快LinkedList 对吗?有没有办法让队列更快,特别是添加(我只需要 poll 添加并检查)。
我可能还需要一个 PriorityQueue 但还没有。

I am looking for a fast queue implementation in Java. I see that LinkedList implements the Queue interface, but it will only be as fast as a LinkedList right? Is there a way to have a queue that will be faster especially for add (I only need poll, add and check for empty). Down the line I may also need a PriorityQueue but not yet.

推荐答案


我看到LinkedList实现了Queue接口,但它只能和LinkedList一样快吗?

I see that LinkedList implements the Queue interface, but it will only be as fast as a LinkedList right?

注意源代码,LinkedList对于Queue.add,Queue.poll和Queue.peek操作是O(1)。

Eyeballing the source code, LinkedList is O(1) for Queue.add, Queue.poll, and Queue.peek operations.

我希望是足够快。

这篇关于Java中的快速队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆