Commit ecc23375 by Mark Wielaard Committed by Mark Wielaard

AbstractMap.java (putAll): Use entrySet size.

	* java/util/AbstractMap.java (putAll): Use entrySet size.
	(toString): Explicitly use getKey() and getValue().

From-SVN: r52008
parent 298f6e4b
2002-04-07 Mark Wielaard <mark@klomp.org> 2002-04-07 Mark Wielaard <mark@klomp.org>
* java/util/AbstractMap.java (putAll): Use entrySet size.
(toString): Explicitly use getKey() and getValue().
2002-04-07 Mark Wielaard <mark@klomp.org>
* java/util/Hashtable.java (contains): Remove NullPointer check. * java/util/Hashtable.java (contains): Remove NullPointer check.
(containsValue): Add NullPointer check. (containsValue): Add NullPointer check.
(remove): Always throw NullPointerException when key (remove): Always throw NullPointerException when key
......
...@@ -353,7 +353,7 @@ public abstract class AbstractMap implements Map ...@@ -353,7 +353,7 @@ public abstract class AbstractMap implements Map
public void putAll(Map m) public void putAll(Map m)
{ {
Iterator entries = m.entrySet().iterator(); Iterator entries = m.entrySet().iterator();
int pos = size(); int pos = m.size();
while (--pos >= 0) while (--pos >= 0)
{ {
Map.Entry entry = (Map.Entry) entries.next(); Map.Entry entry = (Map.Entry) entries.next();
...@@ -425,10 +425,10 @@ public abstract class AbstractMap implements Map ...@@ -425,10 +425,10 @@ public abstract class AbstractMap implements Map
StringBuffer r = new StringBuffer("{"); StringBuffer r = new StringBuffer("{");
for (int pos = size(); pos > 0; pos--) for (int pos = size(); pos > 0; pos--)
{ {
// Append the toString value of the entries rather than calling Map.Entry entry = (Map.Entry) entries.next();
// getKey/getValue. This is more efficient and it matches the JDK r.append(entry.getKey());
// behaviour. r.append('=');
r.append(entries.next()); r.append(entry.getValue());
if (pos > 1) if (pos > 1)
r.append(", "); r.append(", ");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment