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

Method frequency

corpus/java/training/guava/collect/Iterables.java:374–381  ·  view source on GitHub ↗

Returns the number of elements in the specified iterable that equal the specified object. This implementation avoids a full iteration when the iterable is a Multiset or Set. @see Collections#frequency

(Iterable<?> iterable, @Nullable Object element)

Source from the content-addressed store, hash-verified

372 * @see Collections#frequency
373 */
374 public static int frequency(Iterable<?> iterable, @Nullable Object element) {
375 if ((iterable instanceof Multiset)) {
376 return ((Multiset<?>) iterable).count(element);
377 } else if ((iterable instanceof Set)) {
378 return ((Set<?>) iterable).contains(element) ? 1 : 0;
379 }
380 return Iterators.frequency(iterable.iterator(), element);
381 }
382
383 /**
384 * Returns an iterable whose iterators cycle indefinitely over the elements of

Callers

nothing calls this directly

Calls 4

frequencyMethod · 0.95
countMethod · 0.65
containsMethod · 0.65
iteratorMethod · 0.65

Tested by

no test coverage detected