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

Method frequency

output/java_guava/1.4.18/Iterables.java:395–402  ·  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

393
394
395 public static int frequency(Iterable<?> iterable, @Nullable Object element) {
396 if ((iterable instanceof Multiset)) {
397 return ((Multiset<?>) iterable).count(element);
398 } else if ((iterable instanceof Set)) {
399 return ((Set<?>) iterable).contains(element) ? 1 : 0;
400 }
401 return Iterators.frequency(iterable.iterator(), element);
402 }
403
404 /**
405 * 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