How to inspect a Queue, for the oldest element to the newest, without removing the items from the queue
The linked listed implements a deque, you can use a ListIterator to iterate in reverse
final Deque<String> queue = new LinkedList<String>();
queue.add("1");
queue.add("2");
queue.add("3");
queue.add("4");
final Iterator iter = queue.descendingIterator();
// from this you can the iterate the queue
while (iter.hasNext()) {
System.out.println(iter.next());
}
page revision: 15, last edited: 27 Nov 2011 09:34