public boolean retainAll(Collection<T> elements) { return queue.retainAll(elements); }
@Override public boolean retainAll(Collection<?> collection) { assertTrue(Thread.holdsLock(mutex)); return delegate.retainAll(collection); }
@Test(dataProvider = "populated") public void retainAll_withPopulated(Queue<Integer> queue) { Integer first = queue.peek(); assertThat(queue.retainAll(ImmutableList.of(first)), is(true)); assertThat(queue, hasSize(1)); assertThat(queue.contains(first), is(true)); }
@Test(dataProvider = "populated") public void retainAll_toEmpty(Queue<Integer> queue) { assertThat(queue.retainAll(ImmutableList.of()), is(true)); assertThat(queue, is(deeplyEmpty())); }
@Test(dataProvider = "empty") public void retainAll_withEmpty(Queue<Integer> queue) { assertThat(queue.retainAll(ImmutableList.of()), is(false)); assertThat(queue, is(deeplyEmpty())); }
public void testHoldsLockOnAllOperations() { create().element(); create().offer("foo"); create().peek(); create().poll(); create().remove(); create().add("foo"); create().addAll(ImmutableList.of("foo")); create().clear(); create().contains("foo"); create().containsAll(ImmutableList.of("foo")); create().equals(new ArrayDeque<>(ImmutableList.of("foo"))); create().hashCode(); create().isEmpty(); create().iterator(); create().remove("foo"); create().removeAll(ImmutableList.of("foo")); create().retainAll(ImmutableList.of("foo")); create().size(); create().toArray(); create().toArray(new String[] {"foo"}); } }
@Override public boolean retainAll(final Collection c) { return queue.retainAll(c); }
@Test public void zeroQueueOperations() { Queue<Integer> q = Queues.<Integer>empty().get(); List<Integer> vals = Arrays.asList(1, 2, 3); assertThat(q.add(1)).as("add").isFalse(); assertThat(q.addAll(vals)).as("addAll").isFalse(); assertThat(q.offer(1)).as("offer").isFalse(); assertThat(q.peek()).as("peek").isNull(); assertThat(q.poll()).as("poll").isNull(); assertThat(q.contains(1)).as("contains").isFalse(); assertThat(q.iterator()).as("iterator").isEmpty(); assertThatExceptionOfType(NoSuchElementException.class) .as("element") .isThrownBy(q::element); assertThatExceptionOfType(NoSuchElementException.class) .as("remove") .isThrownBy(q::remove); assertThat(q.remove(1)).as("remove").isFalse(); assertThat(q.containsAll(vals)).as("containsAll").isFalse(); assertThat(q.retainAll(vals)).as("retainAll").isFalse(); assertThat(q.removeAll(vals)).as("removeAll").isFalse(); assertThatCode(q::clear).as("clear").doesNotThrowAnyException(); assertThat(q) .hasSize(0) .isEmpty(); assertThat(q.toArray()).as("toArray").isEmpty(); assertThat(q.toArray(new Integer[0])).as("toArray(empty)").isEmpty(); Integer[] array = new Integer[]{-1, -2, -3}; assertThat(q.toArray(array)).as("toArray(pre-filled)").containsExactly(null, -2, -3); }
/** * {@inheritDoc} */ @Override public synchronized boolean retainAll(Collection<?> c) { return queue.retainAll(c); }
/** * @param c * @return * @see java.util.AbstractCollection#retainAll(java.util.Collection) */ public boolean retainAll(Collection<?> c) { return list.retainAll(c); }
@Override public boolean retainAll(final Collection c) { return queue.retainAll(c); }
/** * {@inheritDoc} */ @Override public synchronized boolean retainAll(Collection<?> c) { return queue.retainAll(c); }
@Override public boolean retainAll(Collection<?> c) { return queue.retainAll(c); }
public boolean retainAll(Collection<T> elements) { return queue.retainAll(elements); }
@Override public boolean retainAll(Collection<?> c) { return queue.retainAll(c); }
@Override public boolean retainAll(Collection<?> c) { return q.retainAll(c); }
@Override public boolean retainAll(final Collection c) { return queue.retainAll(c); }
@Override public boolean retainAll(Collection<?> collection) { boolean result = messages.retainAll(collection); this.storeMessageQueue(); return result; }
@Override public boolean retainAll(Collection<?> collection) { boolean result = messages.retainAll(collection); this.storeMessageQueue(); return result; }
@Override public boolean retainAll(Collection<?> collection) { assertTrue(Thread.holdsLock(mutex)); return delegate.retainAll(collection); }