code: private void writeObject(java.io.ObjectOutputStream s)
          throws java.io.IOException {
          // Write out any hidden stuff
          s.defaultWriteObject();
  
          // Write out Comparator
          s.writeObject(m.comparator());
  
          // Write out size
          s.writeInt(m.size());
  
          // Write out all elements in the proper order.
          for (E e : m.keySet())
              s.writeObject(e);
      }
docs: Save the state of the {@code TreeSet} instance to a stream (that is,
  serialize it).
  
  @serialData Emits the comparator used to order this set, or
  {@code null} if it obeys its elements' natural ordering
  (Object), followed by the size of the set (the number of
  elements it contains) (int), followed by all of its
  elements (each an Object) in order (as determined by the
  set's Comparator, or by the elements' natural ordering if
  the set has no Comparator).