MCPcopy
hub / github.com/google/guava / contains

Method contains

guava/src/com/google/common/collect/Iterators.java:180–195  ·  view source on GitHub ↗

Returns {@code true} if {@code iterator} contains {@code element}.

(Iterator<?> iterator, @Nullable Object element)

Source from the content-addressed store, hash-verified

178
179 /** Returns {@code true} if {@code iterator} contains {@code element}. */
180 public static boolean contains(Iterator<?> iterator, @Nullable Object element) {
181 if (element == null) {
182 while (iterator.hasNext()) {
183 if (iterator.next() == null) {
184 return true;
185 }
186 }
187 } else {
188 while (iterator.hasNext()) {
189 if (element.equals(iterator.next())) {
190 return true;
191 }
192 }
193 }
194 return false;
195 }
196
197 /**
198 * Traverses an iterator and removes every element that belongs to the provided collection. The

Callers 10

containsKeyImplMethod · 0.95
containsValueImplMethod · 0.95
containsMethod · 0.95
frequencyMethod · 0.95
containsMethod · 0.95
standardContainsMethod · 0.95
test_contains_null_noMethod · 0.95

Calls 3

nextMethod · 0.65
equalsMethod · 0.65
hasNextMethod · 0.45

Tested by 4

test_contains_null_noMethod · 0.76