TreeSet.java (writeObject): Use a for-loop instead of Iterator.hasNext().

2001-03-06  Bryce McKinlay  <bryce@albatross.co.nz>

	* java/util/TreeSet.java (writeObject): Use a for-loop instead of
	Iterator.hasNext().

2001-03-05  Jochen Hoenicke  <jochen@gnu.org>

	* java/util/TreeMap.java (writeObject): Use defaultWriteObject()
	instead of the new JDK1.2 API.  This is simpler and makes
	back-porting the classes to JDK1.1 trivial.
	(readObject): likewise.

From-SVN: r40252
This commit is contained in:
Bryce McKinlay 2001-03-06 01:04:28 +00:00
parent d97b75bee3
commit 5c409ad3d8
3 changed files with 18 additions and 12 deletions

View file

@ -39,7 +39,7 @@ import java.io.IOException;
* Comparator object, or by the natural ordering of the keys.
*
* The algorithms are adopted from Corman, Leiserson,
* and Rivest's <i>Introduction to Algorithms.<i> In other words,
* and Rivest's <i>Introduction to Algorithms.</i> In other words,
* I cribbed from the same pseudocode as Sun. <em>Any similarity
* between my code and Sun's (if there is any -- I have never looked
* at Sun's) is a result of this fact.</em>
@ -56,7 +56,6 @@ import java.io.IOException;
*
* @author Jon Zeppieri
* @author Bryce McKinlay
* @modified $Id: TreeMap.java,v 1.3 2001/02/16 01:49:40 bryce Exp $
*/
public class TreeMap extends AbstractMap
implements SortedMap, Cloneable, Serializable
@ -777,9 +776,7 @@ public class TreeMap extends AbstractMap
private void writeObject(ObjectOutputStream out) throws IOException
{
ObjectOutputStream.PutField fields = out.putFields();
fields.put("comparator", comparator);
out.writeFields();
out.defaultWriteObject();
Node node = firstNode();
out.writeInt(size);
@ -795,8 +792,7 @@ public class TreeMap extends AbstractMap
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
ObjectInputStream.GetField fields = in.readFields();
comparator = (Comparator) fields.get("comparator", null);
in.defaultReadObject();
int size = in.readInt();
putFromObjStream(in, size, true);
}