guava/src/com/google/common/collect/Serialization.java
static <E> void writeMultiset(Multiset<E> multiset, ObjectOutputStream stream)
      throws IOException {
    int entryCount = multiset.entrySet().size();
    stream.writeInt(entryCount);
    for (Multiset.Entry<E> entry : multiset.entrySet()) {
      stream.writeObject(entry.getElement());
      stream.writeInt(entry.getCount());
    }
  }
static <E> void writeMultiset(Multiset<E> multiset, ObjectOutputStream stream)
      throws IOException {
    int entryCount = multiset.entrySet().size();
    stream.writeInt(entryCount);
    for (Multiset.Entry<E> entry : multiset.entrySet()) {
      stream.writeObject(entry.getElement());
      stream.writeInt(entry.getCount());
    }
  }
Stores the contents of a multiset in an output stream, as part of serialization. It does not
support concurrent multisets whose content may change while the method is running.

<p>The serialized output consists of the number of distinct elements, the first element, its
count, the second element, its count, and so on.