MCPcopy Create free account
hub / github.com/antlr/codebuff / difference

Method difference

output/java_guava/1.4.19/Sets.java:745–771  ·  view source on GitHub ↗

Returns an unmodifiable view of the difference of two sets. The returned set contains all elements that are contained by set1 and not contained by set2. set2 may also contain elements not present in set1; these are simply ignored. The iteration order of the ret

(
    final Set<E> set1, final Set<?> set2)

Source from the content-addressed store, hash-verified

743
744
745 public static <E> SetView<E> difference(
746 final Set<E> set1, final Set<?> set2) {
747 checkNotNull(set1, "set1");
748 checkNotNull(set2, "set2");
749 final Predicate<Object> notInSet2 = Predicates.not(Predicates.in(set2));
750 return new SetView<E>() {
751 @Override
752 public Iterator<E> iterator() {
753 return Iterators.filter(set1.iterator(), notInSet2);
754 }
755
756 @Override
757 public int size() {
758 return Iterators.size(iterator());
759 }
760
761 @Override
762 public boolean isEmpty() {
763 return set2.containsAll(set1);
764 }
765
766 @Override
767 public boolean contains(Object element) {
768 return set1.contains(element) && !set2.contains(element);
769 }
770 };
771 }
772
773 /**
774 * Returns an unmodifiable <b>view</b> of the symmetric difference of two

Callers 3

parallelEdgesMethod · 0.95
unionMethod · 0.95
adjacentEdgesMethod · 0.95

Calls 3

notMethod · 0.95
inMethod · 0.95
checkNotNullMethod · 0.45

Tested by

no test coverage detected