public static int count(Iterable<?> iterable) {
    if (iterable instanceof Collection) {
      return ((Collection<?>)iterable).size();
    }
    int count = 0;
    for (Iterator<?> it = iterable.iterator(); it.hasNext(); it.next()) {
      count += 1;
    }
    return count;
  }
public static int count(Iterable<?> iterable)