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:
@@ -84,7 +84,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
|
|||||||
@Override
|
@Override
|
||||||
public boolean containsKey (Object key)
|
public boolean containsKey (Object key)
|
||||||
{
|
{
|
||||||
return containsKey(((Integer)key).intValue());
|
return (key instanceof Integer) && containsKey(((Integer)key).intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -109,7 +109,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
|
|||||||
@Override
|
@Override
|
||||||
public V get (Object key)
|
public V get (Object key)
|
||||||
{
|
{
|
||||||
return get(((Integer)key).intValue());
|
return (key instanceof Integer) ? get(((Integer)key).intValue()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -161,7 +161,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
|
|||||||
@Override
|
@Override
|
||||||
public V remove (Object key)
|
public V remove (Object key)
|
||||||
{
|
{
|
||||||
return remove(((Integer)key).intValue());
|
return (key instanceof Integer) ? remove(((Integer)key).intValue()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
|
|||||||
Reference in New Issue
Block a user