code: 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());
      }
    }
docs: 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.