diff options
author | Eric Blake <ebb9@byu.net> | 2001-09-18 03:25:11 +0000 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2001-09-18 03:25:11 +0000 |
commit | d678d8849ef08a63bc52dedcaf2a2bfaec608f57 (patch) | |
tree | 04451a6febcd8dad2821b2776bca923fadc059a5 /java/util/HashMap.java | |
parent | 7d5b606e21461176bec3eea1c7adfac27c60e19d (diff) | |
download | classpath-d678d8849ef08a63bc52dedcaf2a2bfaec608f57.tar.gz |
2001-09-17 Eric Blake <ebb9@email.byu.edu>
* java/util/Collections.java (SynchronizedCollection)
(SynchronizedSet): Made package visible.
* java/util/Hashtable.java: More cleanup and documentation. Fix
synchronization issues.
(HashEntry): renamed from Entry, to avoid conflict with Map.Entry.
(clone): Reverted prior change.
* java/util/HashMap.java (clone): Reverted prior change; as
pointed out to me, recursion is worse than looping.
Diffstat (limited to 'java/util/HashMap.java')
-rw-r--r-- | java/util/HashMap.java | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/java/util/HashMap.java b/java/util/HashMap.java index 309c08bee..4f6699f78 100644 --- a/java/util/HashMap.java +++ b/java/util/HashMap.java @@ -111,14 +111,6 @@ public class HashMap extends AbstractMap { super(key, value); } - - Entry copy() - { - Entry e = new Entry(key, value); - if (next != null) - e.next = next.copy(); - return e; - } } /** @@ -373,8 +365,22 @@ public class HashMap extends AbstractMap for (int i=0; i < buckets.length; i++) { Entry e = buckets[i]; - if (e != null) - copy.buckets[i] = e.copy(); + Entry last = null; + + while (e != null) + { + if (last == null) + { + last = new Entry(e.key, e.value); + copy.buckets[i] = last; + } + else + { + last.next = new Entry(e.key, e.value); + last = last.next; + } + e = e.next; + } } return copy; } |