code: public static int count(Iterable seq) {
          if (seq instanceof Collection) {
              return ((Collection) seq).size();
          }
          int c = 0;
          Iterator it = seq.iterator();
          while (it.hasNext()) {
              c++;
              it.next();
          }
          return c;
      }
docs: Count the number of elements in a sequence.