From 9023899c81b758013e99c7982036a5d54a15c49d Mon Sep 17 00:00:00 2001 From: mweaver Date: Wed, 22 Apr 2009 10:03:53 -0600 Subject: [PATCH 1/4] Brought interface in line with Sun --- classpath/java/util/Collection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classpath/java/util/Collection.java b/classpath/java/util/Collection.java index cfde456aab..c2d68500c7 100644 --- a/classpath/java/util/Collection.java +++ b/classpath/java/util/Collection.java @@ -15,7 +15,7 @@ public interface Collection extends Iterable { public boolean isEmpty(); - public boolean contains(T element); + public boolean contains(Object element); public boolean add(T element); From c5dd57f74c76ad615b2129a55e56f32d01462b60 Mon Sep 17 00:00:00 2001 From: mweaver Date: Wed, 22 Apr 2009 10:04:23 -0600 Subject: [PATCH 2/4] Brought more in line with Sun's SDK --- classpath/java/util/Map.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classpath/java/util/Map.java b/classpath/java/util/Map.java index 0b5fa550b2..47edee351e 100644 --- a/classpath/java/util/Map.java +++ b/classpath/java/util/Map.java @@ -15,17 +15,17 @@ public interface Map { public int size(); - public boolean containsKey(K key); + public boolean containsKey(Object obj); - public boolean containsValue(V value); + public boolean containsValue(Object obj); - public V get(K key); + public V get(Object key); public V put(K key, V value); public void putAll(Map elts); - public V remove(K key); + public V remove(Object key); public void clear(); From 34da6da3db4fcb39321b14cd6fc070eec0949af8 Mon Sep 17 00:00:00 2001 From: mweaver Date: Wed, 22 Apr 2009 10:04:38 -0600 Subject: [PATCH 3/4] brought in line with Sun's SDK, should no longer break on values call --- classpath/java/util/HashMap.java | 35 ++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/classpath/java/util/HashMap.java b/classpath/java/util/HashMap.java index 43ee2e8148..2197f9838d 100644 --- a/classpath/java/util/HashMap.java +++ b/classpath/java/util/HashMap.java @@ -107,7 +107,7 @@ public class HashMap implements Map { array = newArray; } - private Cell find(K key) { + private Cell find(Object key) { if (array != null) { int index = helper.hash(key) & (array.length - 1); for (Cell c = array[index]; c != null; c = c.next()) { @@ -158,20 +158,29 @@ public class HashMap implements Map { return c; } - public boolean containsKey(K key) { + public boolean containsKey(Object key) { return find(key) != null; } - public boolean containsValue(V value) { - return values().contains(value); + public boolean containsValue(Object value) { + if (array != null) { + int index = array.length - 1; + for (Cell c = array[index]; c != null; c = c.next()) { + if (helper.equal(value, c.getValue())) { + return true; + } + } + } + + return false; } - public V get(K key) { + public V get(Object key) { Cell c = find(key); return (c == null ? null : c.getValue()); } - public Cell removeCell(K key) { + public Cell removeCell(Object key) { Cell old = null; if (array != null) { int index = helper.hash(key) & (array.length - 1); @@ -213,8 +222,8 @@ public class HashMap implements Map { } } - public V remove(K key) { - Cell c = removeCell(key); + public V remove(Object key) { + Cell c = removeCell((K)key); return (c == null ? null : c.getValue()); } @@ -314,8 +323,8 @@ public class HashMap implements Map { return HashMap.this.isEmpty(); } - public boolean contains(Entry e) { - return containsKey(e.getKey()); + public boolean contains(Object o) { + return (o instanceof Entry) ? containsKey(((Entry)o).getKey()) : false; } public boolean add(Entry e) { @@ -354,7 +363,7 @@ public class HashMap implements Map { return HashMap.this.isEmpty(); } - public boolean contains(K key) { + public boolean contains(Object key) { return containsKey(key); } @@ -368,7 +377,7 @@ public class HashMap implements Map { return change; } - public boolean remove(K key) { + public boolean remove(Object key) { return removeCell(key) != null; } @@ -395,7 +404,7 @@ public class HashMap implements Map { return HashMap.this.isEmpty(); } - public boolean contains(V value) { + public boolean contains(Object value) { return containsValue(value); } From f68f1e58889a42d76570357c11ea52f6dae26b8f Mon Sep 17 00:00:00 2001 From: mweaver Date: Wed, 22 Apr 2009 11:43:22 -0600 Subject: [PATCH 4/4] should be fixed --- classpath/java/util/Map.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/classpath/java/util/Map.java b/classpath/java/util/Map.java index 79867bd267..47edee351e 100644 --- a/classpath/java/util/Map.java +++ b/classpath/java/util/Map.java @@ -15,15 +15,9 @@ public interface Map { public int size(); -<<<<<<< HEAD:classpath/java/util/Map.java public boolean containsKey(Object obj); public boolean containsValue(Object obj); -======= - public boolean containsKey(Object key); - - public boolean containsValue(Object value); ->>>>>>> af784f4cbc18911e29127bcda8110de9bb56d654:classpath/java/util/Map.java public V get(Object key);