@Test public void testPoll() { queue.offer("hello"); queue.offer("hello"); assertEquals("hello", queue.poll()); assertEquals("hello", queue.poll()); }
public E poll() { if (size == 0) return null; E value = objects[remove]; objects[remove] = null; remove++; size--; if (remove == maxSize) { remove = 0; } return value; }
SimpleBoundedQueue extends AbstractQueue<E> { public E poll() { if (size == 0) return null; E value = objects[remove]; objects[remove] = null; remove++; size--; if (remove == maxSize) { remove = 0; } return value; } }
SimpleBoundedQueue extends AbstractQueue<E> { public E poll() { if (size == 0) return null; E value = objects[remove]; objects[remove] = null; remove++; size--; if (remove == maxSize) { remove = 0; } return value; } SimpleBoundedQueue(int maxSize); }
SimpleBoundedQueue extends AbstractQueue<E> { public E poll() { if (size == 0) return null; E value = objects[remove]; objects[remove] = null; remove++; size--; if (remove == maxSize) { remove = 0; } return value; } SimpleBoundedQueue(int maxSize); @Override boolean add(E obj); E pop(); @Override int size(); int remainingCapacity(); boolean offer(E o); E peek(); E poll(); @Override void clear(); @Override Iterator<E> iterator(); }
SimpleBoundedQueue extends AbstractQueue<E> { public E poll() { if (size == 0) return null; E value = objects[remove]; objects[remove] = null; remove++; size--; if (remove == maxSize) { remove = 0; } return value; } SimpleBoundedQueue(int maxSize); @Override boolean add(E obj); E pop(); @Override int size(); int remainingCapacity(); boolean offer(E o); E peek(); E poll(); @Override void clear(); @Override Iterator<E> iterator();  }