### Question:
PriorityDelayQueue extends AbstractQueue<PriorityDelayQueue.QueueElement<E>> implements BlockingQueue<PriorityDelayQueue.QueueElement<E>> { @Override @SuppressWarnings("unchecked") public Iterator<QueueElement<E>> iterator() { QueueElement[][] queueElements = new QueueElement[queues.length][]; lock.lock(); try { for (int i = 0; i < queues.length; i++) { queueElements[i] = queues[i].toArray(new QueueElement[0]); } } finally { lock.unlock(); } List<QueueElement<E>> list = new ArrayList<QueueElement<E>>(); for (QueueElement[] elements : queueElements) { list.addAll(Arrays.asList((QueueElement<E>[]) elements)); } return list.iterator(); } @SuppressWarnings("unchecked")  PriorityDelayQueue(int priorities, long maxWait, TimeUnit unit, int maxSize); int getPriorities(); long getMaxWait(TimeUnit unit); long getMaxSize(); @Override @SuppressWarnings("unchecked") Iterator<QueueElement<E>> iterator(); @Override int size(); int[] sizes(); @Override boolean add(QueueElement<E> queueElement); @Override boolean offer(QueueElement<E> queueElement); @Override QueueElement<E> poll(); @Override QueueElement<E> peek(); @Override void put(QueueElement<E> e); @Override boolean offer(QueueElement<E> e, long timeout, TimeUnit unit); @Override QueueElement<E> take(); @Override QueueElement<E> poll(long timeout, TimeUnit unit); @Override int remainingCapacity(); @Override int drainTo(Collection<? super QueueElement<E>> c); @Override int drainTo(Collection<? super QueueElement<E>> c, int maxElements); @Override void clear(); static final long ANTI_STARVATION_INTERVAL; }### Answer:
@Test public void testIterator() throws Exception { PriorityDelayQueue<Integer> q = new PriorityDelayQueue<Integer>(3, 500, TimeUnit.MILLISECONDS, -1); q.offer(new TestQueueElement<Integer>(1, 1, 10, TimeUnit.MILLISECONDS)); q.offer(new TestQueueElement<Integer>(10, 0, 0, TimeUnit.MILLISECONDS)); q.offer(new TestQueueElement<Integer>(30, 2, 0, TimeUnit.MILLISECONDS)); q.offer(new TestQueueElement<Integer>(20, 1, 0, TimeUnit.MILLISECONDS)); assertEquals(4, q.size()); assertNotNull(q.poll()); assertNotNull(q.poll()); q.offer(new TestQueueElement<Integer>(40, 0, 0, TimeUnit.MILLISECONDS)); q.offer(new TestQueueElement<Integer>(50, 2, 0, TimeUnit.MILLISECONDS)); q.offer(new TestQueueElement<Integer>(60, 1, 0, TimeUnit.MILLISECONDS)); assertEquals(5, q.size()); assertNotNull(q.poll()); assertEquals(4, q.size()); }