From 07add946aac1a64e5e94c2282eb3b3c033ce3867 Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Fri, 16 Feb 2001 01:49:40 +0000 Subject: TreeSet.java (clone): Made subclass safe, use super.clone(), not new. * java/util/TreeSet.java (clone): Made subclass safe, use super.clone(), not new. * java/util/TreeMap.java (clone): Likewise. From-SVN: r39734 --- libjava/java/util/TreeMap.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'libjava/java/util/TreeMap.java') diff --git a/libjava/java/util/TreeMap.java b/libjava/java/util/TreeMap.java index 5057d16..67ecebd 100644 --- a/libjava/java/util/TreeMap.java +++ b/libjava/java/util/TreeMap.java @@ -56,7 +56,7 @@ import java.io.IOException; * * @author Jon Zeppieri * @author Bryce McKinlay - * @modified $Id: TreeMap.java,v 1.1 2001/02/14 04:44:21 bryce Exp $ + * @modified $Id: TreeMap.java,v 1.2 2001/02/14 05:32:31 bryce Exp $ */ public class TreeMap extends AbstractMap implements SortedMap, Cloneable, Serializable @@ -178,8 +178,14 @@ public class TreeMap extends AbstractMap public Object clone() { - TreeMap copy = new TreeMap(); - copy.comparator = comparator; + TreeMap copy = null; + try + { + copy = (TreeMap) super.clone(); + } + catch (CloneNotSupportedException x) + { + } copy.fabricateTree(size); Node node = firstNode(); @@ -991,6 +997,9 @@ public class TreeMap extends AbstractMap parent.right = node; parent = nextparent; } + + // We use the "right" link to maintain a chain of nodes in + // each row until the parent->child links are established. if (last != null) last.right = node; last = node; -- cgit v1.1