code: public static int frequency(Iterable<?> iterable, @NullableDecl Object element) {
      if ((iterable instanceof Multiset)) {
        return ((Multiset<?>) iterable).count(element);
      } else if ((iterable instanceof Set)) {
        return ((Set<?>) iterable).contains(element) ? 1 : 0;
      }
      return Iterators.frequency(iterable.iterator(), element);
    }
docs: 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 {@link Multiset} or {@link Set}.
  
  <p><b>Java 8 users:</b> In most cases, the {@code Stream} equivalent of this method is {@code
  stream.filter(element::equals).count()}. If {@code element} might be null, use {@code
  stream.filter(Predicate.isEqual(element)).count()} instead.
  
  @see java.util.Collections#frequency(Collection, Object) Collections.frequency(Collection,
  Object)