Index: java/util/IdentityHashMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/IdentityHashMap.java,v
retrieving revision 1.14.2.2
diff -u -3 -p -u -r1.14.2.2 IdentityHashMap.java
--- java/util/IdentityHashMap.java 16 Jan 2005 15:15:12 -0000 1.14.2.2
+++ java/util/IdentityHashMap.java 17 Jan 2005 10:07:33 -0000
@@ -78,8 +78,8 @@ import java.io.Serializable;
* iterator, and in the case of the entrySet, the Map.Entry, to
* fail with a address@hidden ConcurrentModificationException}.
*
- * @author Tom Tromey
- * @author Eric Blake
+ * @author Tom Tromey (address@hidden)
+ * @author Eric Blake (address@hidden)
* @see System#identityHashCode(Object)
* @see Collection
* @see Map
@@ -90,8 +90,8 @@ import java.io.Serializable;
* @since 1.4
* @status updated to 1.4
*/
-public class IdentityHashMap extends AbstractMap
- implements Map, Serializable, Cloneable
+public class IdentityHashMap extends AbstractMap
+ implements Map, Serializable, Cloneable
{
/** The default capacity. */
private static final int DEFAULT_CAPACITY = 21;
@@ -134,7 +134,7 @@ public class IdentityHashMap extends Abs
/**
* The cache for address@hidden #entrySet()}.
*/
- private transient Set entries;
+ private transient Set> entries;
/**
* The threshold for rehashing, which is 75% of (table.length / 2).
@@ -177,7 +177,7 @@ public class IdentityHashMap extends Abs
* @param m The map whose elements are to be put in this map
* @throws NullPointerException if m is null
*/
- public IdentityHashMap(Map m)
+ public IdentityHashMap(Map extends K, ? extends V> m)
{
this(Math.max(m.size() << 1, DEFAULT_CAPACITY));
putAll(m);
@@ -274,19 +274,19 @@ public class IdentityHashMap extends Abs
* @see #values()
* @see Map.Entry
*/
- public Set entrySet()
+ public Set> entrySet()
{
if (entries == null)
- entries = new AbstractSet()
+ entries = new AbstractSet>()
{
public int size()
{
return size;
}
- public Iterator iterator()
+ public Iterator> iterator()
{
- return new IdentityIterator(ENTRIES);
+ return new IdentityIterator>(ENTRIES);
}
public void clear()
@@ -358,10 +358,10 @@ public class IdentityHashMap extends Abs
* @see #put(Object, Object)
* @see #containsKey(Object)
*/
- public Object get(Object key)
+ public V get(Object key)
{
int h = hash(key);
- return table[h] == key ? table[h + 1] : null;
+ return (V) (table[h] == key ? table[h + 1] : null);
}
/**
@@ -414,19 +414,19 @@ public class IdentityHashMap extends Abs
* @see #values()
* @see #entrySet()
*/
- public Set keySet()
+ public Set keySet()
{
if (keys == null)
- keys = new AbstractSet()
+ keys = new AbstractSet()
{
public int size()
{
return size;
}
- public Iterator iterator()
+ public Iterator iterator()
{
- return new IdentityIterator(KEYS);
+ return new IdentityIterator(KEYS);
}
public void clear()
@@ -484,7 +484,7 @@ public class IdentityHashMap extends Abs
* @return the prior mapping of the key, or null if there was none
* @see #get(Object)
*/
- public Object put(Object key, Object value)
+ public V put(K key, V value)
{
// Rehash if the load factor is too high.
if (size > threshold)
@@ -499,10 +499,10 @@ public class IdentityHashMap extends Abs
for (int i = old.length - 2; i >= 0; i -= 2)
{
- Object oldkey = old[i];
+ K oldkey = (K) old[i];
if (oldkey != tombstone && oldkey != emptyslot)
// Just use put. This isn't very efficient, but it is ok.
- put(oldkey, old[i + 1]);
+ put(oldkey, (V) old[i + 1]);
}
}
@@ -511,7 +511,7 @@ public class IdentityHashMap extends Abs
{
Object r = table[h + 1];
table[h + 1] = value;
- return r;
+ return (V) r;
}
// At this point, we add a new mapping.
@@ -529,7 +529,7 @@ public class IdentityHashMap extends Abs
* @param m the map to copy
* @throws NullPointerException if m is null
*/
- public void putAll(Map m)
+ public void putAll(Map extends K, ? extends V> m)
{
// Why did Sun specify this one? The superclass does the right thing.
super.putAll(m);
@@ -549,7 +549,7 @@ public class IdentityHashMap extends Abs
* @param key the key used to locate the value to remove
* @return whatever the key mapped to, if present
*/
- public Object remove(Object key)
+ public V remove(Object key)
{
int h = hash(key);
if (table[h] == key)
@@ -559,7 +559,7 @@ public class IdentityHashMap extends Abs
Object r = table[h + 1];
table[h] = tombstone;
table[h + 1] = tombstone;
- return r;
+ return (V) r;
}
return null;
}
@@ -591,19 +591,19 @@ public class IdentityHashMap extends Abs
* @see #keySet()
* @see #entrySet()
*/
- public Collection values()
+ public Collection values()
{
if (values == null)
- values = new AbstractCollection()
+ values = new AbstractCollection()
{
public int size()
{
return size;
}
- public Iterator iterator()
+ public Iterator iterator()
{
- return new IdentityIterator(VALUES);
+ return new IdentityIterator(VALUES);
}
public void clear()
@@ -676,10 +676,10 @@ public class IdentityHashMap extends Abs
* creates the appropriate Map.Entry object with the correct fail-fast
* semantics and identity comparisons.
*
- * @author Tom Tromey
- * @author Eric Blake
+ * @author Tom Tromey (address@hidden)
+ * @author Eric Blake (address@hidden)
*/
- private class IdentityIterator implements Iterator
+ private class IdentityIterator implements Iterator
{
/**
* The type of this Iterator: address@hidden #KEYS}, address@hidden #VALUES},
@@ -720,7 +720,7 @@ public class IdentityHashMap extends Abs
* @throws ConcurrentModificationException if the Map was modified
* @throws NoSuchElementException if there is none
*/
- public Object next()
+ public I next()
{
if (knownMod != modCount)
throw new ConcurrentModificationException();
@@ -736,8 +736,8 @@ public class IdentityHashMap extends Abs
}
while (key == emptyslot || key == tombstone);
- return type == KEYS ? key : (type == VALUES ? table[loc + 1]
- : new IdentityEntry(loc));
+ return (I) (type == KEYS ? key : (type == VALUES ? table[loc + 1]
+ : new IdentityEntry(loc)));
}
/**
@@ -771,7 +771,7 @@ public class IdentityHashMap extends Abs
*
* @author Eric Blake
*/
- private final class IdentityEntry implements Map.Entry
+ private final class IdentityEntry implements Map.Entry
{
/** The location of this entry. */
final int loc;
@@ -815,11 +815,11 @@ public class IdentityHashMap extends Abs
* @throws ConcurrentModificationException if the entry was invalidated
* by modifying the Map or calling Iterator.remove()
*/
- public Object getKey()
+ public EK getKey()
{
if (knownMod != modCount || table[loc] == tombstone)
throw new ConcurrentModificationException();
- return table[loc];
+ return (EK) table[loc];
}
/**
@@ -829,11 +829,11 @@ public class IdentityHashMap extends Abs
* @throws ConcurrentModificationException if the entry was invalidated
* by modifying the Map or calling Iterator.remove()
*/
- public Object getValue()
+ public EV getValue()
{
if (knownMod != modCount || table[loc] == tombstone)
throw new ConcurrentModificationException();
- return table[loc + 1];
+ return (EV) table[loc + 1];
}
/**
@@ -861,11 +861,11 @@ public class IdentityHashMap extends Abs
* @throws ConcurrentModificationException if the entry was invalidated
* by modifying the Map or calling Iterator.remove()
*/
- public Object setValue(Object value)
+ public EV setValue(EV value)
{
if (knownMod != modCount || table[loc] == tombstone)
throw new ConcurrentModificationException();
- Object r = table[loc + 1];
+ EV r = (EV) table[loc + 1];
table[loc + 1] = value;
return r;
}
@@ -905,7 +905,7 @@ public class IdentityHashMap extends Abs
table = new Object[Math.max(num << 1, DEFAULT_CAPACITY) << 1];
// Read key/value pairs.
while (--num >= 0)
- put(s.readObject(), s.readObject());
+ put((K) s.readObject(), (V) s.readObject());
}
/**