[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] [generics] Patch: FYI: random syntax fixes
From: |
Tom Tromey |
Subject: |
[cp-patches] [generics] Patch: FYI: random syntax fixes |
Date: |
11 Jan 2005 18:07:01 -0700 |
I'm checking this in on the generics branch.
This fixes a number of syntax errors as pointed out by Eclipse.
Tom
2005-01-11 Tom Tromey <address@hidden>
* java/util/AbstractList.java (set, add): Fixed argument types.
* java/util/ArrayList.java: Properly handle generic arrays.
* java/util/Arrays.java (sort): Fixed type of temporary 'elem'.
* java/util/BitSet.java (containsAll): Use correct variable name.
* java/util/Collections.java (copy): Use correct
parameterizations.
(min): Likewise.
(putAll): Likewise.
(compare): Fixed argument types.
(sort): Properly handle generic arrays.
* java/util/EnumSet.java (clone): Ignore
CloneNotSupportedException.
(addAll, contains, containsAll, remove, removeAll, retainAll,
copyOf, complementOf): Don't use generic instanceof.
(copyOf): Cast result of 'clone'.
* java/util/HashMap.java (HashMap): Properly handle generic
arrays.
(clone): Likewise.
(rehash): Likewise.
(readObject): Likewise.
(putAll): Don't use generic instanceof.
(getEntry): Likewise.
(putAllInternal): Use correct parameterizations.
(next): Fixed return type.
* java/util/Hashtable.java (Hashtable): Properly handle generic
arrays.
(clone): Likewise.
(rehash): Likewise.
(readObject): Likewise.
(hash): Fixed argument type.
(getEntry): Don't use generic instanceof.
(next): Cast return values.
(nextElement): Fixed return type.
* java/util/LinkedList.java (toArray): Added cast.
(LinkedListItr): Now generic.
* java/util/TreeMap.java (TreeMap): Now generic.
(Node): Likewise.
(left, right, parent): Updated types.
(firstKey, get, headMap, lastKey, remove, subMap, tailMap,
firstNode, getNode): Updated types.
* java/util/TreeSet.java (TreeSet): Fixed cast.
(clone): Likewise.
(readObject): Likewise.
* java/util/Vector.java (Vector): Properly handle generic arrays.
(trimToSize): Likewise.
(ensureCapacity): Likewise.
(toArray): Likewise.
(addAll): Fixed parameterization.
* java/util/WeakHashMap.java (WeakBucket): Now generic.
(value, next): Updated types.
(WeakEntry): Parameterized superinterface.
(key, getKey, getValue, setValue): Updated types.
(getEntry): Fixed type of local 'key'.
(get): Updated.
(put): Fixed return type.
(remove): Updated.
Index: java/util/AbstractList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractList.java,v
retrieving revision 1.21.2.2
diff -u -r1.21.2.2 AbstractList.java
--- java/util/AbstractList.java 3 Nov 2004 18:35:07 -0000 1.21.2.2
+++ java/util/AbstractList.java 12 Jan 2005 01:09:23 -0000
@@ -467,7 +467,7 @@
knownMod = modCount;
}
- public void set(Object o)
+ public void set(E o)
{
checkMod();
if (lastReturned < 0)
@@ -475,7 +475,7 @@
AbstractList.this.set(lastReturned, o);
}
- public void add(Object o)
+ public void add(E o)
{
checkMod();
AbstractList.this.add(position++, o);
Index: java/util/ArrayList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/ArrayList.java,v
retrieving revision 1.25.2.1
diff -u -r1.25.2.1 ArrayList.java
--- java/util/ArrayList.java 15 Aug 2004 07:59:51 -0000 1.25.2.1
+++ java/util/ArrayList.java 12 Jan 2005 01:09:24 -0000
@@ -116,7 +116,7 @@
// Must explicitly check, to get correct exception.
if (capacity < 0)
throw new IllegalArgumentException();
- data = new E[capacity];
+ data = (E[]) new Object[capacity];
}
/**
@@ -151,7 +151,7 @@
// so don't update modCount.
if (size != data.length)
{
- E[] newData = new E[size];
+ E[] newData = (E[]) new Object[size];
System.arraycopy(data, 0, newData, 0, size);
data = newData;
}
@@ -173,7 +173,7 @@
if (minCapacity > current)
{
- E[] newData = new E[Math.max(current * 2, minCapacity)];
+ E[] newData = (E[]) new Object[Math.max(current * 2, minCapacity)];
System.arraycopy(data, 0, newData, 0, size);
data = newData;
}
@@ -268,7 +268,7 @@
*/
public Object[] toArray()
{
- E[] array = new E[size];
+ E[] array = (E[]) new Object[size];
System.arraycopy(data, 0, array, 0, size);
return array;
}
@@ -578,7 +578,7 @@
// the `size' field.
s.defaultReadObject();
int capacity = s.readInt();
- data = new E[capacity];
+ data = (E[]) new Object[capacity];
for (int i = 0; i < size; i++)
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.3
diff -u -r1.20.2.3 Arrays.java
--- java/util/Arrays.java 15 Aug 2004 07:59:51 -0000 1.20.2.3
+++ java/util/Arrays.java 12 Jan 2005 01:09:24 -0000
@@ -2219,7 +2219,7 @@
{
// not already sorted
int j = i;
- Object elem = a[j];
+ T elem = a[j];
do
{
a[j] = a[j - 1];
Index: java/util/BitSet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/BitSet.java,v
retrieving revision 1.13.2.1
diff -u -r1.13.2.1 BitSet.java
--- java/util/BitSet.java 3 Sep 2004 20:59:08 -0000 1.13.2.1
+++ java/util/BitSet.java 12 Jan 2005 01:09:24 -0000
@@ -739,9 +739,9 @@
// This is used by EnumSet for efficiency.
final boolean containsAll(BitSet other)
{
- for (int i = bs.bits.length - 1; i >= 0; i--)
+ for (int i = other.bits.length - 1; i >= 0; i--)
{
- if ((bits[i] & bs.bits[i]) != bs.bits[i])
+ if ((bits[i] & other.bits[i]) != other.bits[i])
return false;
}
return true;
Index: java/util/Collections.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Collections.java,v
retrieving revision 1.28.2.5
diff -u -r1.28.2.5 Collections.java
--- java/util/Collections.java 1 Nov 2004 15:57:08 -0000 1.28.2.5
+++ java/util/Collections.java 12 Jan 2005 01:09:25 -0000
@@ -630,8 +630,8 @@
if (dest.size() < pos)
throw new IndexOutOfBoundsException("Source does not fit in dest");
- Iterator<T> i1 = source.iterator();
- ListIterator<T> i2 = dest.listIterator();
+ Iterator<? extends T> i1 = source.iterator();
+ ListIterator<? super T> i2 = dest.listIterator();
while (--pos >= 0)
{
@@ -824,7 +824,7 @@
public static <T> T min(Collection<? extends T> c,
Comparator<? super T> order)
{
- Iterator<T> itr = c.iterator();
+ Iterator<? extends T> itr = c.iterator();
T min = itr.next(); // throws NoSuchElementExcception
int csize = c.size();
for (int i = 1; i < csize; i++)
@@ -1076,7 +1076,7 @@
* @param b the second object
* @return <, ==, or > 0 according to b.compareTo(a)
*/
- public int compare(Object a, Object b)
+ public int compare(T a, T b)
{
return ((Comparable) b).compareTo(a);
}
@@ -1702,7 +1702,7 @@
*/
public static <T> void sort(List<T> l, Comparator<? super T> c)
{
- Object[] a = l.toArray();
+ T[] a = (T[]) l.toArray();
Arrays.sort(a, c);
ListIterator<T> i = l.listIterator(a.length);
for (int pos = a.length; --pos >= 0; )
@@ -2541,7 +2541,7 @@
}
}
- public void putAll(Map<K, V> map)
+ public void putAll(Map<? extends K, ? extends V> map)
{
synchronized (mutex)
{
@@ -3399,7 +3399,7 @@
{
return new UnmodifiableIterator<T>(c.iterator())
{
- public Object next()
+ public T next()
{
final T e = super.next();
return new Map.Entry<K, V>()
@@ -3466,7 +3466,7 @@
return keys;
}
- public void putAll(Map<K, V> m)
+ public void putAll(Map<? extends K, ? extends V> m)
{
throw new UnsupportedOperationException();
}
Index: java/util/EnumSet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Attic/EnumSet.java,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 EnumSet.java
--- java/util/EnumSet.java 7 Jan 2005 03:42:30 -0000 1.1.2.2
+++ java/util/EnumSet.java 12 Jan 2005 01:09:25 -0000
@@ -61,9 +61,17 @@
public EnumSet<T> clone()
{
- EnumSet<T> r = super.clone();
- r.store = store.clone();
- return r;
+ try
+ {
+ EnumSet<T> r = (EnumSet<T>) super.clone();
+ r.store = (BitSet) store.clone();
+ return r;
+ }
+ catch (CloneNotSupportedException _)
+ {
+ // Can't happen.
+ return null;
+ }
}
public int size()
@@ -113,7 +121,7 @@
public boolean addAll(Collection<? extends T> c)
{
boolean result = false;
- if (c instanceof EnumSet<T>)
+ if (c instanceof EnumSet)
{
EnumSet<T> other = (EnumSet<T>) c;
if (enumClass == other.enumClass)
@@ -143,7 +151,7 @@
public boolean contains(Object o)
{
- if (! (o instanceof Enum<T>))
+ if (! (o instanceof Enum))
return false;
Enum<T> e = (Enum<T>) o;
if (e.getDeclaringClass() != enumClass)
@@ -153,7 +161,7 @@
public boolean containsAll(Collection<?> c)
{
- if (c instanceof EnumSet<T>)
+ if (c instanceof EnumSet)
{
EnumSet<T> other = (EnumSet<T>) c;
if (enumClass == other.enumClass)
@@ -165,7 +173,7 @@
public boolean remove(Object o)
{
- if (! (o instanceof Enum<T>))
+ if (! (o instanceof Enum))
return false;
Enum<T> e = (Enum<T>) o;
if (e.getDeclaringClass() != enumClass)
@@ -177,7 +185,7 @@
public boolean removeAll(Collection<?> c)
{
- if (c instanceof EnumSet<T>)
+ if (c instanceof EnumSet)
{
EnumSet<T> other = (EnumSet<T>) c;
if (enumClass != other.enumClass)
@@ -192,7 +200,7 @@
public boolean retainAll(Collection<?> c)
{
- if (c instanceof EnumSet<T>)
+ if (c instanceof EnumSet)
{
EnumSet<T> other = (EnumSet<T>) c;
if (enumClass != other.enumClass)
@@ -228,7 +236,7 @@
// We can't just use `other.clone' since we don't want to make a
// subclass.
EnumSet<T> r = new EnumSet<T>();
- r.store = other.store.clone();
+ r.store = (BitSet) other.store.clone();
r.cardinality = other.cardinality;
r.enumClass = other.enumClass;
return r;
@@ -236,7 +244,7 @@
public static <T extends Enum<T>> EnumSet<T> copyOf(Collection<T> other)
{
- if (other instanceof EnumSet<T>)
+ if (other instanceof EnumSet)
return copyOf((EnumSet<T>) other);
EnumSet<T> r = new EnumSet<T>();
for (T val : other)
@@ -258,7 +266,7 @@
public static <T extends Enum<T>> EnumSet<T> complementOf(EnumSet<T> other)
{
EnumSet<T> r = new EnumSet<T>();
- r.store = other.store.clone();
+ r.store = (BitSet) other.store.clone();
r.store.flip(0, r.store.size());
r.cardinality = r.store.size() - other.cardinality;
r.enumClass = other.enumClass;
Index: java/util/HashMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/HashMap.java,v
retrieving revision 1.28.2.3
diff -u -r1.28.2.3 HashMap.java
--- java/util/HashMap.java 1 Nov 2004 15:57:08 -0000 1.28.2.3
+++ java/util/HashMap.java 12 Jan 2005 01:09:25 -0000
@@ -256,7 +256,7 @@
if (initialCapacity == 0)
initialCapacity = 1;
- buckets = new HashEntry<K, V>[initialCapacity];
+ buckets = (HashEntry<K, V>[]) new HashEntry[initialCapacity];
this.loadFactor = loadFactor;
threshold = (int) (initialCapacity * loadFactor);
}
@@ -386,7 +386,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<K, V>)
+ if (e instanceof AbstractMap.BasicMapEntry)
{
AbstractMap.BasicMapEntry<? extends K, ? extends V> entry
= (AbstractMap.BasicMapEntry<? extends K, ? extends V>) e;
@@ -485,7 +485,7 @@
{
// This is impossible.
}
- copy.buckets = new HashEntry<K, V>[buckets.length];
+ copy.buckets = (HashEntry<K, V>[]) new HashEntry[buckets.length];
copy.putAllInternal(this);
// Clear the entry cache. AbstractMap.clone() does the others.
copy.entries = null;
@@ -661,7 +661,7 @@
// Package visible, for use in nested classes.
final HashEntry<K, V> getEntry(Object o)
{
- if (! (o instanceof Map.Entry<K, V>))
+ if (! (o instanceof Map.Entry))
return null;
Map.Entry<K, V> me = (Map.Entry<K, V>) o;
K key = me.getKey();
@@ -716,7 +716,7 @@
while (itr.hasNext())
{
size++;
- Map.Entry<K, V> e = itr.next();
+ Map.Entry<? extends K, ? extends V> e = itr.next();
K key = e.getKey();
int idx = hash(key);
addEntry(key, e.getValue(), idx, false);
@@ -738,7 +738,7 @@
int newcapacity = (buckets.length * 2) + 1;
threshold = (int) (newcapacity * loadFactor);
- buckets = new HashEntry<K, V>[newcapacity];
+ buckets = (HashEntry<K, V>[]) new HashEntry[newcapacity];
for (int i = oldBuckets.length - 1; i >= 0; i--)
{
@@ -800,7 +800,7 @@
s.defaultReadObject();
// Read and use capacity, followed by key/value pairs.
- buckets = new HashEntry<K, V>[s.readInt()];
+ buckets = (HashEntry<K, V>[]) new HashEntry[s.readInt()];
int len = s.readInt();
size = len;
while (len-- > 0)
@@ -868,7 +868,7 @@
* @throws ConcurrentModificationException if the HashMap was modified
* @throws NoSuchElementException if there is none
*/
- public Object next()
+ public T next()
{
if (knownMod != modCount)
throw new ConcurrentModificationException();
@@ -883,10 +883,10 @@
next = e.next;
last = e;
if (type == VALUES)
- return e.value;
+ return (T) e.value;
if (type == KEYS)
- return e.key;
- return e;
+ return (T) e.key;
+ return (T) e;
}
/**
Index: java/util/Hashtable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Hashtable.java,v
retrieving revision 1.32.2.2
diff -u -r1.32.2.2 Hashtable.java
--- java/util/Hashtable.java 6 Nov 2004 22:11:53 -0000 1.32.2.2
+++ java/util/Hashtable.java 12 Jan 2005 01:09:25 -0000
@@ -269,7 +269,7 @@
if (initialCapacity == 0)
initialCapacity = 1;
- buckets = new HashEntry<K, V>[initialCapacity];
+ buckets = (HashEntry<K, V>[]) new HashEntry[initialCapacity];
this.loadFactor = loadFactor;
threshold = (int) (initialCapacity * loadFactor);
}
@@ -562,7 +562,7 @@
{
// This is impossible.
}
- copy.buckets = new HashEntry<K, V>[buckets.length];
+ copy.buckets = (HashEntry<K, V>[]) new HashEntry[buckets.length];
copy.putAllInternal(this);
// Clear the caches.
copy.keys = null;
@@ -820,7 +820,7 @@
* @return the bucket number
* @throws NullPointerException if key is null
*/
- private int hash(K key)
+ private int hash(Object key)
{
// Note: Inline Math.abs here, for less method overhead, and to avoid
// a bootstrap dependency, since Math relies on native methods.
@@ -839,7 +839,7 @@
// Package visible, for use in nested classes.
HashEntry<K, V> getEntry(Object o)
{
- if (! (o instanceof Map.Entry<K, V>))
+ if (! (o instanceof Map.Entry))
return null;
K key = ((Map.Entry<K, V>) o).getKey();
if (key == null)
@@ -899,7 +899,7 @@
int newcapacity = (buckets.length * 2) + 1;
threshold = (int) (newcapacity * loadFactor);
- buckets = new HashEntry<K, V>[newcapacity];
+ buckets = (HashEntry<K, V>[]) new HashEntry[newcapacity];
for (int i = oldBuckets.length - 1; i >= 0; i--)
{
@@ -975,13 +975,13 @@
s.defaultReadObject();
// Read and use capacity.
- buckets = new HashEntry<K, V>[s.readInt()];
+ buckets = (HashEntry<K, V>[]) new HashEntry[s.readInt()];
int len = s.readInt();
// Read and use key/value pairs.
// TODO: should we be defensive programmers, and check for illegal nulls?
while (--len >= 0)
- put(s.readObject(), s.readObject());
+ put((K) s.readObject(), (V) s.readObject());
}
/**
@@ -1061,10 +1061,10 @@
next = e.next;
last = e;
if (type == VALUES)
- return e.value;
+ return (T) e.value;
if (type == KEYS)
- return e.key;
- return e;
+ return (T) e.key;
+ return (T) e;
}
/**
@@ -1141,7 +1141,7 @@
* @return the next element
* @throws NoSuchElementException if there is none.
*/
- public Object nextElement()
+ public T nextElement()
{
if (count == 0)
throw new NoSuchElementException("Hashtable Enumerator");
@@ -1152,7 +1152,7 @@
e = buckets[--idx];
next = e.next;
- return type == VALUES ? e.value : e.key;
+ return type == VALUES ? (T) e.value : (T) e.key;
}
} // class Enumerator
} // class Hashtable
Index: java/util/LinkedList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/LinkedList.java,v
retrieving revision 1.23.2.3
diff -u -r1.23.2.3 LinkedList.java
--- java/util/LinkedList.java 8 Aug 2004 06:38:26 -0000 1.23.2.3
+++ java/util/LinkedList.java 12 Jan 2005 01:09:25 -0000
@@ -701,7 +701,7 @@
Entry<T> e = first;
for (int i = 0; i < size; i++)
{
- a[i] = e.data;
+ a[i] = (T) e.data;
e = e.next;
}
return a;
@@ -796,7 +796,7 @@
* @author Original author unknown
* @author Eric Blake <address@hidden>
*/
- private final class LinkedListItr<T> implements ListIterator<T>
+ private final class LinkedListItr implements ListIterator<T>
{
/** Number of modifications we know about. */
private int knownMod = modCount;
Index: java/util/TreeMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/TreeMap.java,v
retrieving revision 1.23
diff -u -r1.23 TreeMap.java
--- java/util/TreeMap.java 22 Apr 2004 11:24:39 -0000 1.23
+++ java/util/TreeMap.java 12 Jan 2005 01:09:26 -0000
@@ -90,8 +90,8 @@
* @since 1.2
* @status updated to 1.4
*/
-public class TreeMap extends AbstractMap
- implements SortedMap, Cloneable, Serializable
+public class TreeMap<K, V> extends AbstractMap<K, V>
+ implements SortedMap<K, V>, Cloneable, Serializable
{
// Implementation note:
// A red-black tree is a binary search tree with the additional properties
@@ -162,25 +162,25 @@
*
* @author Eric Blake <address@hidden>
*/
- private static final class Node extends AbstractMap.BasicMapEntry
+ private static final class Node<K, V> extends AbstractMap.BasicMapEntry<K, V>
{
// All fields package visible for use by nested classes.
/** The color of this node. */
int color;
/** The left child node. */
- Node left = nil;
+ Node<K, V> left = nil;
/** The right child node. */
- Node right = nil;
+ Node<K, V> right = nil;
/** The parent node. */
- Node parent = nil;
+ Node<K, V> parent = nil;
/**
* Simple constructor.
* @param key the key
* @param value the value
*/
- Node(Object key, Object value, int color)
+ Node(K key, V value, int color)
{
super(key, value);
this.color = color;
@@ -417,7 +417,7 @@
* @return the first key
* @throws NoSuchElementException if the map is empty
*/
- public Object firstKey()
+ public K firstKey()
{
if (root == nil)
throw new NoSuchElementException();
@@ -438,7 +438,7 @@
* @see #put(Object, Object)
* @see #containsKey(Object)
*/
- public Object get(Object key)
+ public V get(Object key)
{
// Exploit fact that nil.value == null.
return getNode(key).value;
@@ -459,7 +459,7 @@
* @throws NullPointerException if toKey is null, but the comparator does not
* tolerate null elements
*/
- public SortedMap headMap(Object toKey)
+ public SortedMap<K, V> headMap(K toKey)
{
return new SubMap(nil, toKey);
}
@@ -518,7 +518,7 @@
* @return the last key
* @throws NoSuchElementException if the map is empty
*/
- public Object lastKey()
+ public K lastKey()
{
if (root == nil)
throw new NoSuchElementException("empty");
@@ -618,13 +618,13 @@
* @throws NullPointerException if key is null, but the comparator does
* not tolerate nulls
*/
- public Object remove(Object key)
+ public V remove(K key)
{
- Node n = getNode(key);
+ Node<K, V> n = getNode(key);
if (n == nil)
return null;
// Note: removeNode can alter the contents of n, so save value now.
- Object result = n.value;
+ V result = n.value;
removeNode(n);
return result;
}
@@ -658,7 +658,7 @@
* comparator does not tolerate null elements
* @throws IllegalArgumentException if fromKey is greater than toKey
*/
- public SortedMap subMap(Object fromKey, Object toKey)
+ public SortedMap<K, V> subMap(K fromKey, K toKey)
{
return new SubMap(fromKey, toKey);
}
@@ -678,7 +678,7 @@
* @throws NullPointerException if fromKey is null, but the comparator
* does not tolerate null elements
*/
- public SortedMap tailMap(Object fromKey)
+ public SortedMap<K, V> tailMap(K fromKey)
{
return new SubMap(fromKey, nil);
}
@@ -926,7 +926,7 @@
*
* @return the first node
*/
- final Node firstNode()
+ final Node<K, V> firstNode()
{
// Exploit fact that nil.left == nil.
Node node = root;
@@ -942,7 +942,7 @@
* @param key the key to search for
* @return the node where the key is found, or nil
*/
- final Node getNode(Object key)
+ final Node<K, V> getNode(K key)
{
Node current = root;
while (current != nil)
@@ -1732,14 +1732,14 @@
return count;
}
- public SortedMap subMap(Object fromKey, Object toKey)
+ public SortedMap<K, V> subMap(K fromKey, K toKey)
{
if (! keyInRange(fromKey) || ! keyInRange(toKey))
throw new IllegalArgumentException("key outside range");
return new SubMap(fromKey, toKey);
}
- public SortedMap tailMap(Object fromKey)
+ public SortedMap<K, V> tailMap(K fromKey)
{
if (! keyInRange(fromKey))
throw new IllegalArgumentException("key outside range");
Index: java/util/TreeSet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/TreeSet.java,v
retrieving revision 1.15.2.3
diff -u -r1.15.2.3 TreeSet.java
--- java/util/TreeSet.java 7 Jan 2005 03:42:30 -0000 1.15.2.3
+++ java/util/TreeSet.java 12 Jan 2005 01:09:26 -0000
@@ -151,7 +151,7 @@
{
map = new TreeMap<T, String>(sortedSet.comparator());
Iterator<? extends T> itr = sortedSet.iterator();
- ((TreeMap<T>) map).putKeysLinear(itr, sortedSet.size());
+ ((TreeMap<T, String>) map).putKeysLinear(itr, sortedSet.size());
}
/**
@@ -217,7 +217,7 @@
{
copy = (TreeSet<T>) super.clone();
// Map may be either TreeMap or TreeMap.SubMap, hence the ugly casts.
- copy.map = (SortedMap<T>) ((AbstractMap<T>) map).clone();
+ copy.map = (SortedMap<T, String>) ((AbstractMap<T, String>)
map).clone();
}
catch (CloneNotSupportedException x)
{
@@ -412,7 +412,7 @@
s.defaultReadObject();
Comparator<? super T> comparator = (Comparator<? super T>) s.readObject();
int size = s.readInt();
- map = new TreeMap<T>(comparator);
- ((TreeMap<T>) map).putFromObjStream(s, size, false);
+ map = new TreeMap<T, String>(comparator);
+ ((TreeMap<T, String>) map).putFromObjStream(s, size, false);
}
}
Index: java/util/Vector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Vector.java,v
retrieving revision 1.20.2.2
diff -u -r1.20.2.2 Vector.java
--- java/util/Vector.java 8 Aug 2004 06:38:26 -0000 1.20.2.2
+++ java/util/Vector.java 12 Jan 2005 01:09:26 -0000
@@ -129,7 +129,7 @@
public Vector(Collection<? extends T> c)
{
elementCount = c.size();
- elementData = c.toArray(new T[elementCount]);
+ elementData = c.toArray((T[]) new Object[elementCount]);
}
/**
@@ -145,7 +145,7 @@
{
if (initialCapacity < 0)
throw new IllegalArgumentException();
- elementData = new T[initialCapacity];
+ elementData = (T[]) new Object[initialCapacity];
this.capacityIncrement = capacityIncrement;
}
@@ -188,7 +188,7 @@
// vector since that is a much less likely case; it's more efficient to
// not do the check and lose a bit of performance in that infrequent case
- T[] newArray = new T[elementCount];
+ T[] newArray = (T[]) new Object[elementCount];
System.arraycopy(elementData, 0, newArray, 0, elementCount);
elementData = newArray;
}
@@ -214,7 +214,7 @@
else
newCapacity = elementData.length + capacityIncrement;
- T[] newArray = new T[Math.max(newCapacity, minCapacity)];
+ T[] newArray = (T[]) new Object[Math.max(newCapacity, minCapacity)];
System.arraycopy(elementData, 0, newArray, 0, elementCount);
elementData = newArray;
@@ -778,7 +778,7 @@
public synchronized boolean addAll(int index, Collection<? extends T> c)
{
checkBoundInclusive(index);
- Iterator itr = c.iterator();
+ Iterator<? extends T> itr = c.iterator();
int csize = c.size();
modCount++;
Index: java/util/WeakHashMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/WeakHashMap.java,v
retrieving revision 1.18.2.1
diff -u -r1.18.2.1 WeakHashMap.java
--- java/util/WeakHashMap.java 10 Jan 2005 18:25:48 -0000 1.18.2.1
+++ java/util/WeakHashMap.java 12 Jan 2005 01:09:26 -0000
@@ -353,19 +353,19 @@
*
* @author Jochen Hoenicke
*/
- private static class WeakBucket extends WeakReference
+ private static class WeakBucket<K, V> extends WeakReference<K>
{
/**
* The value of this entry. The key is stored in the weak
* reference that we extend.
*/
- Object value;
+ V value;
/**
* The next bucket describing another entry that uses the same
* slot.
*/
- WeakBucket next;
+ WeakBucket<K, V> next;
/**
* The slot of this entry. This should be
@@ -388,7 +388,7 @@
* @param slot the slot. This must match the slot where this bucket
* will be enqueued.
*/
- public WeakBucket(Object key, ReferenceQueue queue, Object value,
+ public WeakBucket(K key, ReferenceQueue queue, V value,
int slot)
{
super(key, queue);
@@ -401,18 +401,18 @@
* current bucket. It also keeps a strong reference to the
* key; bad things may happen otherwise.
*/
- class WeakEntry implements Map.Entry
+ class WeakEntry implements Map.Entry<K, V>
{
/**
* The strong ref to the key.
*/
- Object key;
+ K key;
/**
* Creates a new entry for the key.
* @param key the key
*/
- public WeakEntry(Object key)
+ public WeakEntry(K key)
{
this.key = key;
}
@@ -430,7 +430,7 @@
* Returns the key.
* @return the key
*/
- public Object getKey()
+ public K getKey()
{
return key == NULL_KEY ? null : key;
}
@@ -439,7 +439,7 @@
* Returns the value.
* @return the value
*/
- public Object getValue()
+ public V getValue()
{
return value;
}
@@ -450,9 +450,9 @@
* @param newVal the new value
* @return the old value
*/
- public Object setValue(Object newVal)
+ public V setValue(V newVal)
{
- Object oldVal = value;
+ V oldVal = value;
value = newVal;
return oldVal;
}
@@ -495,7 +495,7 @@
*/
WeakEntry getEntry()
{
- final Object key = this.get();
+ final K key = this.get();
if (key == null)
return null;
return new WeakEntry(key);
@@ -762,7 +762,7 @@
public V get(Object key)
{
cleanQueue();
- WeakBucket.WeakEntry entry = internalGet(key);
+ WeakBucket<K, V>.WeakEntry entry = internalGet(key);
return entry == null ? null : entry.getValue();
}
@@ -774,10 +774,10 @@
* null if the key wasn't in this map, or if the mapped value
* was explicitly set to null.
*/
- public Object put(K key, V value)
+ public V put(K key, V value)
{
cleanQueue();
- WeakBucket.WeakEntry entry = internalGet(key);
+ WeakBucket<K, V>.WeakEntry entry = internalGet(key);
if (entry != null)
return entry.setValue(value);
@@ -799,7 +799,7 @@
public V remove(Object key)
{
cleanQueue();
- WeakBucket.WeakEntry entry = internalGet(key);
+ WeakBucket<K, V>.WeakEntry entry = internalGet(key);
if (entry == null)
return null;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] [generics] Patch: FYI: random syntax fixes,
Tom Tromey <=