将队列转换为列表 [英] Convert a Queue to List
本文介绍了将队列转换为列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在保持队列顺序的同时将Queue
转换为List
的最快方法是什么?
What is the fastest way to convert a Queue
into a List
while keeping the Queue order?
推荐答案
最快的方法是首先使用LinkedList,该LinkedList可用作列表或队列.
The fastest is to use a LinkedList in the first place which can be used as a List or a Queue.
Queue q = new LinkedList();
List l = (List) q;
否则,您需要复制一份
List l = new ArrayList(q);
这篇关于将队列转换为列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文