Esempio n. 1
0
  /**
   * Save the state of this <tt>HashSet</tt> instance to a stream (that is, serialize this set).
   *
   * @serialData The capacity of the backing <tt>HashMap</tt> instance (int), and its load factor
   *     (float) are emitted, followed by the size of the set (the number of elements it contains)
   *     (int), followed by all of its elements (each an Object) in no particular order.
   */
  private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
    // Write out any hidden serialization magic
    s.defaultWriteObject();

    // Write out HashMap capacity and load factor
    s.writeInt(map.capacity());
    s.writeFloat(map.loadFactor());

    // Write out size
    s.writeInt(map.size());

    // Write out all elements in the proper order.
    for (Iterator i = map.keySet().iterator(); i.hasNext(); ) s.writeObject(i.next());
  }