From: Bryce McKinlay Date: Tue, 6 Mar 2001 01:04:28 +0000 (+0000) Subject: TreeSet.java (writeObject): Use a for-loop instead of Iterator.hasNext(). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5c409ad3d88f5d8fba3e15bd9b337a9a99886161;p=gcc.git TreeSet.java (writeObject): Use a for-loop instead of Iterator.hasNext(). 2001-03-06 Bryce McKinlay * java/util/TreeSet.java (writeObject): Use a for-loop instead of Iterator.hasNext(). 2001-03-05 Jochen Hoenicke * 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 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index d0b8e6a43be..9de90404a17 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,7 +1,18 @@ +2001-03-06 Bryce McKinlay + + * java/util/TreeSet.java (writeObject): Use a for-loop instead of + Iterator.hasNext(). + +2001-03-05 Jochen Hoenicke + + * 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. + 2001-03-01 Per Bothner Changes merged from Kawa's gnu.math. - * java/math/BigInteger.java * gnu/gcj/math/MPN.java (rshift0): New method handles zero shift count. (rshift(int[],int[],int,int): Removed - not needed. (gcd): Use rshift0 rather than rshift. diff --git a/libjava/java/util/TreeMap.java b/libjava/java/util/TreeMap.java index 26e3fd6dfba..59d6079e32a 100644 --- a/libjava/java/util/TreeMap.java +++ b/libjava/java/util/TreeMap.java @@ -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 Introduction to Algorithms. In other words, + * and Rivest's Introduction to Algorithms. In other words, * I cribbed from the same pseudocode as Sun. 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. @@ -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); } diff --git a/libjava/java/util/TreeSet.java b/libjava/java/util/TreeSet.java index c6875b8d05a..ba852131a13 100644 --- a/libjava/java/util/TreeSet.java +++ b/libjava/java/util/TreeSet.java @@ -44,8 +44,6 @@ import java.io.ObjectOutputStream; * TreeSet is a part of the JDK1.2 Collections API. * * @author Jon Zeppieri - * @version $Revision: 1.2 $ - * @modified $Id: TreeSet.java,v 1.2 2001/02/15 03:59:57 bryce Exp $ */ public class TreeSet extends AbstractSet @@ -269,11 +267,12 @@ public class TreeSet extends AbstractSet private void writeObject(ObjectOutputStream out) throws IOException { Iterator itr = map.keySet().iterator(); + int size = map.size(); out.writeObject(map.comparator()); - out.writeInt(map.size()); + out.writeInt(size); - while (itr.hasNext()) + for (int i = 0; i < size; i++) out.writeObject(itr.next()); }