public static <T> void writeCollection(DataOutput out, Iterable<? extends T> seq, Writer<? super T> writable) throws IOException {
    Collection<? extends T> col = seq instanceof Collection? (Collection<? extends T>)seq : Iterators.collect(seq, new SmartList<>());
    out.writeInt(col.size());
    for (T t : col) {
      writable.write(t);
    }
  }
public static <T> void writeCollection(DataOutput out, Iterable<? extends T> seq, Writer<? super T> writable)