Make get(), containsKey(), and remove() tolerant of non-Integer objects.

Our IntSets now do this, including the keySet returned by this class.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2677 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray.j.greenwell
2009-12-10 20:18:17 +00:00
parent 2d20fd3454
commit 84c6cce89a
+3 -3
View File
@@ -84,7 +84,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
@Override
public boolean containsKey (Object key)
{
return containsKey(((Integer)key).intValue());
return (key instanceof Integer) && containsKey(((Integer)key).intValue());
}
// documentation inherited
@@ -109,7 +109,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
@Override
public V get (Object key)
{
return get(((Integer)key).intValue());
return (key instanceof Integer) ? get(((Integer)key).intValue()) : null;
}
// documentation inherited
@@ -161,7 +161,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
@Override
public V remove (Object key)
{
return remove(((Integer)key).intValue());
return (key instanceof Integer) ? remove(((Integer)key).intValue()) : null;
}
// documentation inherited