PartialOrderedSet extends HashSet<E> { @Override public boolean removeIf(final Predicate<? super E> filter) { Objects.requireNonNull(filter); boolean removed = false; final Iterator<E> each = this.order.keySet().iterator(); while (each.hasNext()) { E next = each.next(); if (filter.test(next)) { this.remove(next); removed = true; } } return removed; } PartialOrderedSet(final PartialOrderedSet<E> original);  PartialOrderedSet(); void addABeforeB(final E a, final E b); void requireABeforeB(final E a, final E b); boolean allowsABeforeB(final E a, final E b); Map<E, Set<E>> getOrder(); boolean isADirectlyBeforeB(final E a, final E b); Set<E> getTransitiveClosure(final E e); Set<E> getTransitiveClosure(final Set<E> subSet); boolean isReflexive(); List<E> getTotalOrder(); void merge(final PartialOrderedSet<? extends E> set); void addAll(final PartialOrderedSet<? extends E> set); @Override String toString(); List<E> getLinearization(); @Override Iterator<E> iterator(); @Override void clear(); @Override boolean removeAll(final Collection<?> c); @Override boolean retainAll(final Collection<?> c); @Override boolean removeIf(final Predicate<? super E> filter); @Override boolean remove(final Object e); @Override int hashCode(); @SuppressWarnings("rawtypes") @Override boolean equals(final Object obj);  }
@Test public void testRemoveIf() { this.set.removeIf(s -> "c".equals(s)); assertFalse("c was removed but contains still says it's in.", this.set.contains("c")); assertTrue("Since c was removed from the set, d before a should be allowed but isn't.", this.set.allowsABeforeB(D, A)); assertTrue("Since c was removed from the set, d before b should be allowed but isn't.", this.set.allowsABeforeB(D, B)); }