[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] [generics] Patch: FYI: Merge in Matthias' changes
From: |
Tom Tromey |
Subject: |
[cp-patches] [generics] Patch: FYI: Merge in Matthias' changes |
Date: |
15 Aug 2004 01:42:10 -0600 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
I'm checking this in on the generics branch.
I diff'd Matthias' generics changes against the current generics
branch, and went through the patch applying fix to the tree. This
caught a fair number of errors in the current code.
Tom
Index: ChangeLog
from Matthias Pfisterer <address@hidden>
Tom Tromey <address@hidden>
* java/util/HashMap.java (HashMap): Fixed parameterization in
`new'.
(putAll): Fixed parameterization.
(containsValue): Likewise.
(clone): Likewise.
(getEntry): Likewise.
* java/util/Dictionary.java (remove): Fixed parameterization.
* java/util/Collections.java (shuffle): Fixed indentation and
type of iterator.
(copy): Fixed argument types.
(SingletonSet.containsAll): Fixed type parameterizations.
(SingletonList.containsAll): Likewise.
(EmptyMap.get): Likewise.
(isSequential): Likewise.
(EmptySet): Genericized.
(EmptyList): Likewise.
(EmptyMap): Likewise.
(compare): Likewise.
(SynchronizedCollection.containsAll): Fixed type
parameterization.
(SynchronizedCollection.iterator): Likewise.
(SynchronizedList.listIterator): Likewise.
(SynchronizedList.subList): Likewise.
(SynchronizedMap.keySet): Likewise.
(SynchronizedMap.values): Likewise.
(synchronizedSortedSet): Likewise.
(UnmodifiableCollection.containsAll): Likewise.
(UnmodifiableList.listIterator): Likewise.
* java/util/Calendar.java: Implement Comparable<Calendar>.
(compareTo): New method.
* java/util/Arrays.java (sort): Declare type variable.
(asList): Corrected argument type.
(ArrayList): Genericized.
* java/util/ArrayList.java: Genericized.
* java/util/AbstractSet.java (removeAll): Fix type errors in
iterator declarations.
* java/util/AbstractSequentialList.java (addAll): Genericize
iterator `i'.
Index: java/util/AbstractSequentialList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractSequentialList.java,v
retrieving revision 1.15.2.1
diff -u -r1.15.2.1 AbstractSequentialList.java
--- java/util/AbstractSequentialList.java 5 Aug 2004 21:09:36 -0000 1.15.2.1
+++ java/util/AbstractSequentialList.java 15 Aug 2004 07:56:11 -0000
@@ -143,7 +143,7 @@
{
Iterator<? extends E> ci = c.iterator();
int size = c.size();
- ListIterator i = listIterator(index);
+ ListIterator<E> i = listIterator(index);
for (int pos = size; pos > 0; pos--)
i.add(ci.next());
return size > 0;
Index: java/util/AbstractSet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractSet.java,v
retrieving revision 1.14.2.1
diff -u -r1.14.2.1 AbstractSet.java
--- java/util/AbstractSet.java 5 Aug 2004 21:09:36 -0000 1.14.2.1
+++ java/util/AbstractSet.java 15 Aug 2004 07:56:11 -0000
@@ -125,17 +125,19 @@
{
int oldsize = size();
int count = c.size();
- Iterator<E> i;
if (oldsize < count)
{
- for (i = iterator(), count = oldsize; count > 0; count--)
- if (c.contains(i.next()))
- i.remove();
+ for (Iterator<E> i = iterator(), count = oldsize; count > 0; count--)
+ {
+ if (c.contains(i.next()))
+ i.remove();
+ }
}
else
- for (i = c.iterator(); count > 0; count--)
- remove(i.next());
+ {
+ for (Iterator<?> i = c.iterator(); count > 0; count--)
+ remove(i.next());
+ }
return oldsize != size();
}
-
}
Index: java/util/ArrayList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/ArrayList.java,v
retrieving revision 1.25
diff -u -r1.25 ArrayList.java
--- java/util/ArrayList.java 22 Apr 2004 11:24:39 -0000 1.25
+++ java/util/ArrayList.java 15 Aug 2004 07:56:11 -0000
@@ -81,8 +81,8 @@
* @see AbstractList
* @status updated to 1.4
*/
-public class ArrayList extends AbstractList
- implements List, RandomAccess, Cloneable, Serializable
+public class ArrayList<E> extends AbstractList<E>
+ implements List<E>, RandomAccess, Cloneable, Serializable
{
/**
* Compatible with JDK 1.2
@@ -103,7 +103,7 @@
/**
* Where the data is stored.
*/
- private transient Object[] data;
+ private transient E[] data;
/**
* Construct a new ArrayList with the supplied initial capacity.
@@ -116,7 +116,7 @@
// Must explicitly check, to get correct exception.
if (capacity < 0)
throw new IllegalArgumentException();
- data = new Object[capacity];
+ data = new E[capacity];
}
/**
@@ -135,7 +135,7 @@
* @param c the collection whose elements will initialize this list
* @throws NullPointerException if c is null
*/
- public ArrayList(Collection c)
+ public ArrayList(Collection<? extends E> c)
{
this((int) (c.size() * 1.1f));
addAll(c);
@@ -151,7 +151,7 @@
// so don't update modCount.
if (size != data.length)
{
- Object[] newData = new Object[size];
+ E[] newData = new E[size];
System.arraycopy(data, 0, newData, 0, size);
data = newData;
}
@@ -173,7 +173,7 @@
if (minCapacity > current)
{
- Object[] newData = new Object[Math.max(current * 2, minCapacity)];
+ E[] newData = new E[Math.max(current * 2, minCapacity)];
System.arraycopy(data, 0, newData, 0, size);
data = newData;
}
@@ -247,11 +247,11 @@
*/
public Object clone()
{
- ArrayList clone = null;
+ ArrayList<E> clone = null;
try
{
- clone = (ArrayList) super.clone();
- clone.data = (Object[]) data.clone();
+ clone = (ArrayList<E>) super.clone();
+ clone.data = (E[]) data.clone();
}
catch (CloneNotSupportedException e)
{
@@ -268,7 +268,7 @@
*/
public Object[] toArray()
{
- Object[] array = new Object[size];
+ E[] array = new E[size];
System.arraycopy(data, 0, array, 0, size);
return array;
}
@@ -287,11 +287,10 @@
* an element in this list
* @throws NullPointerException if a is null
*/
- public Object[] toArray(Object[] a)
+ public <T> T[] toArray(T[] a)
{
if (a.length < size)
- a = (Object[]) Array.newInstance(a.getClass().getComponentType(),
- size);
+ a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
else if (a.length > size)
a[size] = null;
System.arraycopy(data, 0, a, 0, size);
@@ -304,7 +303,7 @@
* @param index the index of the element we are fetching
* @throws IndexOutOfBoundsException if index < 0 || index >= size()
*/
- public Object get(int index)
+ public E get(int index)
{
checkBoundExclusive(index);
return data[index];
@@ -318,10 +317,10 @@
* @return the element previously at the specified index
* @throws IndexOutOfBoundsException if index < 0 || index >= 0
*/
- public Object set(int index, Object e)
+ public E set(int index, E e)
{
checkBoundExclusive(index);
- Object result = data[index];
+ E result = data[index];
data[index] = e;
return result;
}
@@ -332,7 +331,7 @@
* @param e the element to be appended to this list
* @return true, the add will always succeed
*/
- public boolean add(Object e)
+ public boolean add(E e)
{
modCount++;
if (size == data.length)
@@ -349,7 +348,7 @@
* @param e the item being added
* @throws IndexOutOfBoundsException if index < 0 || index > size()
*/
- public void add(int index, Object e)
+ public void add(int index, E e)
{
checkBoundInclusive(index);
modCount++;
@@ -368,10 +367,10 @@
* @return the removed Object
* @throws IndexOutOfBoundsException if index < 0 || index >= size()
*/
- public Object remove(int index)
+ public E remove(int index)
{
checkBoundExclusive(index);
- Object r = data[index];
+ E r = data[index];
modCount++;
if (index != --size)
System.arraycopy(data, index + 1, data, index, size - index);
@@ -403,7 +402,7 @@
* @return true if the list was modified, in other words c is not empty
* @throws NullPointerException if c is null
*/
- public boolean addAll(Collection c)
+ public boolean addAll(Collection<? extends E> c)
{
return addAll(size, c);
}
@@ -417,10 +416,10 @@
* @throws IndexOutOfBoundsException if index < 0 || index > 0
* @throws NullPointerException if c is null
*/
- public boolean addAll(int index, Collection c)
+ public boolean addAll(int index, Collection<? extends E> c)
{
checkBoundInclusive(index);
- Iterator itr = c.iterator();
+ Iterator<? extends E> itr = c.iterator();
int csize = c.size();
modCount++;
@@ -497,7 +496,7 @@
* @return true if this list changed
* @throws NullPointerException if c is null
*/
- boolean removeAllInternal(Collection c)
+ boolean removeAllInternal(Collection<?> c)
{
int i;
int j;
@@ -525,7 +524,7 @@
* @throws NullPointerException if c is null
* @since 1.2
*/
- boolean retainAllInternal(Collection c)
+ boolean retainAllInternal(Collection<?> c)
{
int i;
int j;
@@ -579,8 +578,8 @@
// the `size' field.
s.defaultReadObject();
int capacity = s.readInt();
- data = new Object[capacity];
+ data = new E[capacity];
for (int i = 0; i < size; i++)
- data[i] = s.readObject();
+ data[i] = (E) s.readObject();
}
}
Index: java/util/Arrays.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Arrays.java,v
retrieving revision 1.20.2.2
diff -u -r1.20.2.2 Arrays.java
--- java/util/Arrays.java 8 Aug 2004 06:38:26 -0000 1.20.2.2
+++ java/util/Arrays.java 15 Aug 2004 07:56:11 -0000
@@ -2148,7 +2148,7 @@
* @throws NullPointerException if a null element is compared with natural
* ordering (only possible when c is null)
*/
- public static void sort(T[] a, Comparator<? super T> c)
+ public static <T> void sort(T[] a, Comparator<? super T> c)
{
sort(a, 0, a.length, c);
}
@@ -2198,8 +2198,8 @@
* @throws NullPointerException if a null element is compared with natural
* ordering (only possible when c is null)
*/
- public static void sort(T[] a, int fromIndex, int toIndex,
- Comparator<? super T> c)
+ public static <T> void sort(T[] a, int fromIndex, int toIndex,
+ Comparator<? super T> c)
{
if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex " + fromIndex
@@ -2331,7 +2331,7 @@
* @see RandomAccess
* @see Arrays.ArrayList
*/
- public static <T> List<T> asList(final Object[] a) // fixme `T...'
+ public static <T> List<T> asList(final T... a)
{
return new Arrays.ArrayList(a);
}
@@ -2345,7 +2345,7 @@
* @author Eric Blake <address@hidden>
* @status updated to 1.4
*/
- private static final class ArrayList extends AbstractList
+ private static final class ArrayList<E> extends AbstractList<E>
implements Serializable, RandomAccess
{
// We override the necessary methods, plus others which will be much
@@ -2360,14 +2360,14 @@
* The array we are viewing.
* @serial the array
*/
- private final Object[] a;
+ private final E[] a;
/**
* Construct a list view of the array.
* @param a the array to view
* @throws NullPointerException if a is null
*/
- ArrayList(Object[] a)
+ ArrayList(E[] a)
{
// We have to explicitly check.
if (a == null)
@@ -2375,7 +2375,7 @@
this.a = a;
}
- public Object get(int index)
+ public E get(int index)
{
return a[index];
}
@@ -2385,9 +2385,9 @@
return a.length;
}
- public Object set(int index, Object element)
+ public E set(int index, E element)
{
- Object old = a[index];
+ E old = a[index];
a[index] = element;
return old;
}
@@ -2420,12 +2420,12 @@
return (Object[]) a.clone();
}
- public Object[] toArray(Object[] array)
+ public <T> T[] toArray(T[] array)
{
int size = a.length;
if (array.length < size)
- array = (Object[])
- Array.newInstance(array.getClass().getComponentType(), size);
+ array = (T[]) Array.newInstance(array.getClass().getComponentType(),
+ size);
else if (array.length > size)
array[size] = null;
Index: java/util/Calendar.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Calendar.java,v
retrieving revision 1.25
diff -u -r1.25 Calendar.java
--- java/util/Calendar.java 15 Jun 2004 22:40:38 -0000 1.25
+++ java/util/Calendar.java 15 Aug 2004 07:56:11 -0000
@@ -102,7 +102,8 @@
* @see TimeZone
* @see java.text.DateFormat
*/
-public abstract class Calendar implements Serializable, Cloneable
+public abstract class Calendar
+ implements Serializable, Cloneable, Comparable<Calendar>
{
/**
* Constant representing the era time field.
@@ -965,6 +966,13 @@
return max;
}
+ public int compareTo(Calendar other)
+ {
+ if (time < other.time)
+ return -1;
+ return time == other.time ? 0 : 1;
+ }
+
/**
* Return a clone of this object.
*/
Index: java/util/Collections.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Collections.java,v
retrieving revision 1.28.2.3
diff -u -r1.28.2.3 Collections.java
--- java/util/Collections.java 8 Aug 2004 06:44:29 -0000 1.28.2.3
+++ java/util/Collections.java 15 Aug 2004 07:56:12 -0000
@@ -89,7 +89,7 @@
* @param l the list to check
* @return true if it should be treated as sequential-access
*/
- private static boolean isSequential(List l)
+ private static boolean isSequential(List<?> l)
{
return ! (l instanceof RandomAccess) && l.size() > LARGE_LIST_SIZE;
}
@@ -113,7 +113,7 @@
*
* @author Eric Blake <address@hidden>
*/
- private static final class EmptySet extends AbstractSet
+ private static final class EmptySet<T> extends AbstractSet<T>
implements Serializable
{
/**
@@ -140,9 +140,9 @@
* Returns an iterator that does not iterate.
*/
// This is really cheating! I think it's perfectly valid, though.
- public Iterator iterator()
+ public Iterator<T> iterator()
{
- return EMPTY_LIST.iterator();
+ return (Iterator<T>) EMPTY_LIST.iterator();
}
// The remaining methods are optional, but provide a performance
@@ -158,7 +158,7 @@
/**
* This is true only if the given collection is also empty.
*/
- public boolean containsAll(Collection c)
+ public boolean containsAll(Collection<?> c)
{
return c.isEmpty();
}
@@ -190,7 +190,7 @@
/**
* Always succeeds with false result.
*/
- public boolean removeAll(Collection c)
+ public boolean removeAll(Collection<?> c)
{
return false;
}
@@ -198,7 +198,7 @@
/**
* Always succeeds with false result.
*/
- public boolean retainAll(Collection c)
+ public boolean retainAll(Collection<?> c)
{
return false;
}
@@ -214,7 +214,7 @@
/**
* We don't even need to use reflection!
*/
- public Object[] toArray(Object[] a)
+ public T[] toArray(T[] a)
{
if (a.length > 0)
a[0] = null;
@@ -243,7 +243,7 @@
*
* @author Eric Blake <address@hidden>
*/
- private static final class EmptyList extends AbstractList
+ private static final class EmptyList<T> extends AbstractList<T>
implements Serializable, RandomAccess
{
/**
@@ -269,7 +269,7 @@
/**
* No matter the index, it is out of bounds.
*/
- public Object get(int index)
+ public T get(int index)
{
throw new IndexOutOfBoundsException();
}
@@ -287,7 +287,7 @@
/**
* This is true only if the given collection is also empty.
*/
- public boolean containsAll(Collection c)
+ public boolean containsAll(Collection<?> c)
{
return c.isEmpty();
}
@@ -335,7 +335,7 @@
/**
* Always succeeds with false result.
*/
- public boolean removeAll(Collection c)
+ public boolean removeAll(Collection<?> c)
{
return false;
}
@@ -343,7 +343,7 @@
/**
* Always succeeds with false result.
*/
- public boolean retainAll(Collection c)
+ public boolean retainAll(Collection<?> c)
{
return false;
}
@@ -359,7 +359,7 @@
/**
* We don't even need to use reflection!
*/
- public Object[] toArray(Object[] a)
+ public T[] toArray(T[] a)
{
if (a.length > 0)
a[0] = null;
@@ -387,7 +387,7 @@
*
* @author Eric Blake <address@hidden>
*/
- private static final class EmptyMap extends AbstractMap
+ private static final class EmptyMap<K, V> extends AbstractMap<K, V>
implements Serializable
{
/**
@@ -405,7 +405,7 @@
/**
* There are no entries.
*/
- public Set entrySet()
+ public Set<Entry<K, V>> entrySet()
{
return EMPTY_SET;
}
@@ -439,7 +439,7 @@
/**
* No mappings, so this returns null.
*/
- public Object get(Object o)
+ public V get(Object o)
{
return null;
}
@@ -455,7 +455,7 @@
/**
* No entries.
*/
- public Set keySet()
+ public Set<K> keySet()
{
return EMPTY_SET;
}
@@ -463,7 +463,7 @@
/**
* Remove always succeeds, with null result.
*/
- public Object remove(Object o)
+ public V remove(Object o)
{
return null;
}
@@ -480,7 +480,7 @@
* No entries. Technically, EMPTY_SET, while more specific than a general
* Collection, will work. Besides, that's what the JDK uses!
*/
- public Collection values()
+ public Collection<V> values()
{
return EMPTY_SET;
}
@@ -501,7 +501,7 @@
* clever, but worth it for removing a duplicate of the search code.
* Note: This code is also used in Arrays (for sort as well as search).
*/
- static final int compare(Object o1, Object o2, Comparator c)
+ static final int compare(Object o1, Object o2, Comparator<?> c)
{
return c == null ? ((Comparable) o1).compareTo(o2) : c.compare(o1, o2);
}
@@ -624,7 +624,7 @@
* @throws UnsupportedOperationException if dest.listIterator() does not
* support the set operation
*/
- public static <T> void copy(List<T> dest, List<T> source)
+ public static <T> void copy(List<? super T> dest, List<? extends T> source)
{
int pos = source.size();
if (dest.size() < pos)
@@ -1019,7 +1019,7 @@
ListIterator<T> i2 = l.listIterator(pos2);
while (pos1 < pos2)
{
- Object o = i1.next();
+ T o = i1.next();
i1.set(i2.previous());
i2.set(o);
++pos1;
@@ -1040,7 +1040,7 @@
*/
public static <T> Comparator<T> reverseOrder()
{
- return (Comparator<T>) rcInstance; // fixme?
+ return (Comparator<T>) rcInstance;
}
/**
@@ -1179,10 +1179,10 @@
if (defaultRandom == null)
{
synchronized (Collections.class)
- {
- if (defaultRandom == null)
- defaultRandom = new Random();
- }
+ {
+ if (defaultRandom == null)
+ defaultRandom = new Random();
+ }
}
shuffle(l, defaultRandom);
}
@@ -1220,7 +1220,7 @@
public static void shuffle(List<?> l, Random r)
{
int lsize = l.size();
- ListIterator i = l.listIterator(lsize);
+ ListIterator<?> i = l.listIterator(lsize);
boolean sequential = isSequential(l);
Object[] a = null; // stores a copy of the list for the sequential case
@@ -1344,9 +1344,9 @@
/**
* This is true if the other collection only contains the element.
*/
- public boolean containsAll(Collection c)
+ public boolean containsAll(Collection<?> c)
{
- Iterator i = c.iterator();
+ Iterator<?> i = c.iterator();
int pos = c.size();
while (--pos >= 0)
if (! equals(i.next(), element))
@@ -1454,9 +1454,9 @@
/**
* This is true if the other collection only contains the element.
*/
- public boolean containsAll(Collection c)
+ public boolean containsAll(Collection<?> c)
{
- Iterator i = c.iterator();
+ Iterator<?> i = c.iterator();
int pos = c.size();
while (--pos >= 0)
if (! equals(i.next(), element))
@@ -1613,7 +1613,7 @@
/**
* Single entry.
*/
- public V get(K key)
+ public V get(Object key)
{
return equals(key, k) ? v : null;
}
@@ -1849,7 +1849,7 @@
}
}
- public boolean containsAll(Collection c1)
+ public boolean containsAll(Collection<?> c1)
{
synchronized (mutex)
{
@@ -1869,7 +1869,7 @@
{
synchronized (mutex)
{
- return new SynchronizedIterator(mutex, c.iterator());
+ return new SynchronizedIterator<T>(mutex, c.iterator());
}
}
@@ -2123,7 +2123,7 @@
{
synchronized (mutex)
{
- return new SynchronizedListIterator(mutex, list.listIterator());
+ return new SynchronizedListIterator<T>(mutex, list.listIterator());
}
}
@@ -2131,7 +2131,8 @@
{
synchronized (mutex)
{
- return new SynchronizedListIterator(mutex, list.listIterator(index));
+ return new SynchronizedListIterator<T>(mutex,
+ list.listIterator(index));
}
}
@@ -2155,7 +2156,8 @@
{
synchronized (mutex)
{
- return new SynchronizedList(mutex, list.subList(fromIndex, toIndex));
+ return new SynchronizedList<T>(mutex,
+ list.subList(fromIndex, toIndex));
}
}
} // class SynchronizedList
@@ -2497,7 +2499,7 @@
}
}
- public V get(K key)
+ public V get(Object key)
{
synchronized (mutex)
{
@@ -2526,7 +2528,7 @@
if (keys == null)
synchronized (mutex)
{
- keys = new SynchronizedSet(mutex, m.keySet());
+ keys = new SynchronizedSet<K>(mutex, m.keySet());
}
return keys;
}
@@ -2576,7 +2578,7 @@
if (values == null)
synchronized (mutex)
{
- values = new SynchronizedCollection(mutex, m.values());
+ values = new SynchronizedCollection<V>(mutex, m.values());
}
return values;
}
@@ -2818,7 +2820,7 @@
* @return a synchronized view of the sorted set
* @see Serializable
*/
- public static SortedSet<T> synchronizedSortedSet(SortedSet<T> s)
+ public static <T> SortedSet<T> synchronizedSortedSet(SortedSet<T> s)
{
return new SynchronizedSortedSet<T>(s);
}
@@ -2993,7 +2995,7 @@
return c.contains(o);
}
- public boolean containsAll(Collection c1)
+ public boolean containsAll(Collection<?> c1)
{
return c.containsAll(c1);
}
@@ -3176,12 +3178,12 @@
public ListIterator<T> listIterator()
{
- return new UnmodifiableListIterator(list.listIterator());
+ return new UnmodifiableListIterator<T>(list.listIterator());
}
public ListIterator<T> listIterator(int index)
{
- return new UnmodifiableListIterator(list.listIterator(index));
+ return new UnmodifiableListIterator<T>(list.listIterator(index));
}
public T remove(int index)
@@ -3322,7 +3324,6 @@
/**
* Cache the entry set.
*/
- // fixme Set<? extends Entry<K, V>> ?
private transient Set<Map.Entry<K, V>> entries;
/**
@@ -3438,7 +3439,7 @@
return m.equals(o);
}
- public V get(K key)
+ public V get(Object key)
{
return m.get(key);
}
Index: java/util/Dictionary.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Dictionary.java,v
retrieving revision 1.9.2.1
diff -u -r1.9.2.1 Dictionary.java
--- java/util/Dictionary.java 5 Aug 2004 21:09:36 -0000 1.9.2.1
+++ java/util/Dictionary.java 15 Aug 2004 07:56:12 -0000
@@ -125,7 +125,7 @@
* @return the value associated with the removed key
* @throws NullPointerException if key is null
*/
- public abstract V remove(K key);
+ public abstract V remove(Object key);
/**
* Returns the number of values currently in this Dictionary.
Index: java/util/HashMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/HashMap.java,v
retrieving revision 1.28.2.1
diff -u -r1.28.2.1 HashMap.java
--- java/util/HashMap.java 5 Aug 2004 21:09:36 -0000 1.28.2.1
+++ java/util/HashMap.java 15 Aug 2004 07:56:12 -0000
@@ -256,7 +256,7 @@
if (initialCapacity == 0)
initialCapacity = 1;
- buckets = new HashEntry[initialCapacity];
+ buckets = new HashEntry<K, V>[initialCapacity];
this.loadFactor = loadFactor;
threshold = (int) (initialCapacity * loadFactor);
}
@@ -385,7 +385,7 @@
{
Map.Entry<? extends K, ? extends V> e = itr.next();
// Optimize in case the Entry is one of our own.
- if (e instanceof AbstractMap.BasicMapEntry)
+ if (e instanceof AbstractMap.BasicMapEntry<K, V>)
{
AbstractMap.BasicMapEntry<? extends K, ? extends V> entry
= (AbstractMap.BasicMapEntry<? extends K, ? extends V>) e;
@@ -456,7 +456,7 @@
{
for (int i = buckets.length - 1; i >= 0; i--)
{
- HashEntry e = buckets[i];
+ HashEntry<K, V> e = buckets[i];
while (e != null)
{
if (equals(value, e.value))
@@ -475,16 +475,16 @@
*/
public Object clone()
{
- HashMap copy = null;
+ HashMap<K, V> copy = null;
try
{
- copy = (HashMap) super.clone();
+ copy = (HashMap<K, V>) super.clone();
}
catch (CloneNotSupportedException x)
{
// This is impossible.
}
- copy.buckets = new HashEntry[buckets.length];
+ copy.buckets = new HashEntry<K, V>[buckets.length];
copy.putAllInternal(this);
// Clear the entry cache. AbstractMap.clone() does the others.
copy.entries = null;
@@ -660,7 +660,7 @@
// Package visible, for use in nested classes.
final HashEntry<K, V> getEntry(Object o)
{
- if (! (o instanceof Map.Entry))
+ if (! (o instanceof Map.Entry<K, V>))
return null;
Map.Entry<K, V> me = (Map.Entry<K, V>) o;
K key = me.getKey();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] [generics] Patch: FYI: Merge in Matthias' changes,
Tom Tromey <=