@Test public void testRemoveFirst() throws JMSException { List<JmsInboundMessageDispatch> messages = createFullRangePrioritySet(); for (JmsInboundMessageDispatch envelope: messages) { queue.enqueue(envelope); } for (byte i = 9; i >= 0; --i) { JmsInboundMessageDispatch first = queue.dequeueNoWait(); assertEquals(i, first.getMessage().getJMSPriority()); } assertTrue(queue.isEmpty()); }
private JmsInboundMessageDispatch removeFirst() { if (this.size > 0) { for (int i = MAX_PRIORITY; i >= 0; i--) { LinkedList<JmsInboundMessageDispatch> list = lists[i]; if (!list.isEmpty()) { this.size--; return list.removeFirst(); } } } return null; }
PriorityMessageQueue implements MessageQueue { private JmsInboundMessageDispatch removeFirst() { if (this.size > 0) { for (int i = MAX_PRIORITY; i >= 0; i--) { LinkedList<JmsInboundMessageDispatch> list = lists[i]; if (!list.isEmpty()) { this.size--; return list.removeFirst(); } } } return null; } }
PriorityMessageQueue implements MessageQueue { private JmsInboundMessageDispatch removeFirst() { if (this.size > 0) { for (int i = MAX_PRIORITY; i >= 0; i--) { LinkedList<JmsInboundMessageDispatch> list = lists[i]; if (!list.isEmpty()) { this.size--; return list.removeFirst(); } } } return null; } @SuppressWarnings("unchecked")  PriorityMessageQueue(); }
PriorityMessageQueue implements MessageQueue { private JmsInboundMessageDispatch removeFirst() { if (this.size > 0) { for (int i = MAX_PRIORITY; i >= 0; i--) { LinkedList<JmsInboundMessageDispatch> list = lists[i]; if (!list.isEmpty()) { this.size--; return list.removeFirst(); } } } return null; } @SuppressWarnings("unchecked")  PriorityMessageQueue(); @Override void enqueue(JmsInboundMessageDispatch envelope); @Override void enqueueFirst(JmsInboundMessageDispatch envelope); @Override final JmsInboundMessageDispatch dequeue(long timeout); @Override final JmsInboundMessageDispatch dequeueNoWait(); @Override final void start(); @Override final void stop(); @Override final void close(); @Override final boolean isRunning(); @Override final boolean isClosed(); @Override boolean isEmpty(); @Override int size(); @Override void clear(); }
PriorityMessageQueue implements MessageQueue { private JmsInboundMessageDispatch removeFirst() { if (this.size > 0) { for (int i = MAX_PRIORITY; i >= 0; i--) { LinkedList<JmsInboundMessageDispatch> list = lists[i]; if (!list.isEmpty()) { this.size--; return list.removeFirst(); } } } return null; } @SuppressWarnings("unchecked")  PriorityMessageQueue(); @Override void enqueue(JmsInboundMessageDispatch envelope); @Override void enqueueFirst(JmsInboundMessageDispatch envelope); @Override final JmsInboundMessageDispatch dequeue(long timeout); @Override final JmsInboundMessageDispatch dequeueNoWait(); @Override final void start(); @Override final void stop(); @Override final void close(); @Override final boolean isRunning(); @Override final boolean isClosed(); @Override boolean isEmpty(); @Override int size(); @Override void clear();  }