예제 #1
0
파일: HashSet.java 프로젝트: imu2008/jcute
  /**
   * 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());
  }
예제 #2
0
파일: HashSet.java 프로젝트: imu2008/jcute
 /**
  * Returns an iterator over the elements in this set. The elements are returned in no particular
  * order.
  *
  * @return an Iterator over the elements in this set.
  * @see ConcurrentModificationException
  */
 public Iterator iterator() {
   return map.keySet().iterator();
 }