@Test public void testPoll() { assertNull(queue.poll()); PriorityQueue<TestObject> testList = new PriorityQueue<TestObject>(CAPACITY, new TestObjectComparator()); for (int i = 0; i < CAPACITY; ++i) { TestObject obj = new TestObject(i, i); testList.add(obj); queue.offer(obj); } for (int i = 0; i < CAPACITY; ++i) { assertEquals(testList.poll(), queue.poll()); } assertNull(null, queue.poll()); }
public E poll() { E result = null; lock.lock(); try { if (queue.size() > 0) { result = queue.poll(); notFull.signal(); } } finally { lock.unlock(); } return result; }
BoundedPriorityBlockingQueue extends AbstractQueue<E> implements BlockingQueue<E> { public E poll() { E result = null; lock.lock(); try { if (queue.size() > 0) { result = queue.poll(); notFull.signal(); } } finally { lock.unlock(); } return result; } }
BoundedPriorityBlockingQueue extends AbstractQueue<E> implements BlockingQueue<E> { public E poll() { E result = null; lock.lock(); try { if (queue.size() > 0) { result = queue.poll(); notFull.signal(); } } finally { lock.unlock(); } return result; } BoundedPriorityBlockingQueue(int capacity,
      Comparator<? super E> comparator); }
BoundedPriorityBlockingQueue extends AbstractQueue<E> implements BlockingQueue<E> { public E poll() { E result = null; lock.lock(); try { if (queue.size() > 0) { result = queue.poll(); notFull.signal(); } } finally { lock.unlock(); } return result; } BoundedPriorityBlockingQueue(int capacity,
      Comparator<? super E> comparator); boolean offer(E e); void put(E e); boolean offer(E e, long timeout, TimeUnit unit); E take(); E poll(); E poll(long timeout, TimeUnit unit); E peek(); int size(); Iterator<E> iterator(); Comparator<? super E> comparator(); int remainingCapacity(); boolean remove(Object o); boolean contains(Object o); int drainTo(Collection<? super E> c); int drainTo(Collection<? super E> c, int maxElements); }
BoundedPriorityBlockingQueue extends AbstractQueue<E> implements BlockingQueue<E> { public E poll() { E result = null; lock.lock(); try { if (queue.size() > 0) { result = queue.poll(); notFull.signal(); } } finally { lock.unlock(); } return result; } BoundedPriorityBlockingQueue(int capacity,
      Comparator<? super E> comparator); boolean offer(E e); void put(E e); boolean offer(E e, long timeout, TimeUnit unit); E take(); E poll(); E poll(long timeout, TimeUnit unit); E peek(); int size(); Iterator<E> iterator(); Comparator<? super E> comparator(); int remainingCapacity(); boolean remove(Object o); boolean contains(Object o); int drainTo(Collection<? super E> c); int drainTo(Collection<? super E> c, int maxElements);  }