Some type parameter clarification.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2348 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2008-07-26 22:11:38 +00:00
parent 10eeeca31b
commit 9ef52a4929
3 changed files with 34 additions and 34 deletions
+13 -13
View File
@@ -36,8 +36,8 @@ import static com.samskivert.Log.log;
* functionality (which we'd just extend directly if those pig fuckers hadn't * functionality (which we'd just extend directly if those pig fuckers hadn't
* made the instance variables private). * made the instance variables private).
*/ */
public abstract class BaseArrayList<T> extends AbstractList<T> public abstract class BaseArrayList<E> extends AbstractList<E>
implements List<T>, RandomAccess, Cloneable, Serializable implements List<E>, RandomAccess, Cloneable, Serializable
{ {
// documentation inherited from interface // documentation inherited from interface
public int size () public int size ()
@@ -88,9 +88,9 @@ public abstract class BaseArrayList<T> extends AbstractList<T>
} }
@SuppressWarnings("unchecked") // documentation inherited from interface @SuppressWarnings("unchecked") // documentation inherited from interface
public boolean add (T o) public boolean add (E o)
{ {
_elements = (T[])ListUtil.add(_elements, _size, o); _elements = (E[])ListUtil.add(_elements, _size, o);
_size++; _size++;
return true; return true;
} }
@@ -106,34 +106,34 @@ public abstract class BaseArrayList<T> extends AbstractList<T>
} }
// documentation inherited from interface // documentation inherited from interface
public T get (int index) public E get (int index)
{ {
rangeCheck(index, false); rangeCheck(index, false);
return _elements[index]; return _elements[index];
} }
// documentation inherited from interface // documentation inherited from interface
public T set (int index, T element) public E set (int index, E element)
{ {
rangeCheck(index, false); rangeCheck(index, false);
T old = _elements[index]; E old = _elements[index];
_elements[index] = element; _elements[index] = element;
return old; return old;
} }
@SuppressWarnings("unchecked") // documentation inherited from interface @SuppressWarnings("unchecked") // documentation inherited from interface
public void add (int index, T element) public void add (int index, E element)
{ {
rangeCheck(index, true); rangeCheck(index, true);
_elements = (T[])ListUtil.insert(_elements, index, element); _elements = (E[])ListUtil.insert(_elements, index, element);
_size++; _size++;
} }
@SuppressWarnings("unchecked") // documentation inherited from interface @SuppressWarnings("unchecked") // documentation inherited from interface
public T remove (int index) public E remove (int index)
{ {
rangeCheck(index, false); rangeCheck(index, false);
T oval = (T)ListUtil.remove(_elements, index); E oval = (E)ListUtil.remove(_elements, index);
_size--; _size--;
return oval; return oval;
} }
@@ -166,7 +166,7 @@ public abstract class BaseArrayList<T> extends AbstractList<T>
public Object clone () public Object clone ()
{ {
try { try {
BaseArrayList<T> dup = (BaseArrayList<T>)super.clone(); BaseArrayList<E> dup = (BaseArrayList<E>)super.clone();
if (_elements != null) { if (_elements != null) {
dup._elements = _elements.clone(); dup._elements = _elements.clone();
} }
@@ -179,7 +179,7 @@ public abstract class BaseArrayList<T> extends AbstractList<T>
} }
/** The array of elements in our list. */ /** The array of elements in our list. */
protected T[] _elements; protected E[] _elements;
/** The number of elements in our list. */ /** The number of elements in our list. */
protected int _size; protected int _size;
+12 -12
View File
@@ -365,12 +365,12 @@ public class Collections
* default access and pointlessly preventing people from properly * default access and pointlessly preventing people from properly
* reusing their code. Yay! * reusing their code. Yay!
*/ */
protected static class SynchronizedSet<T> protected static class SynchronizedSet<E>
extends SynchronizedCollection<T> implements Set<T> { extends SynchronizedCollection<E> implements Set<E> {
SynchronizedSet(Set<T> s) { SynchronizedSet(Set<E> s) {
super(s); super(s);
} }
SynchronizedSet(Set<T> s, Object mutex) { SynchronizedSet(Set<E> s, Object mutex) {
super(s, mutex); super(s, mutex);
} }
@@ -426,18 +426,18 @@ public class Collections
* default access and pointlessly preventing people from properly * default access and pointlessly preventing people from properly
* reusing their code. Yay! * reusing their code. Yay!
*/ */
protected static class SynchronizedCollection<T> protected static class SynchronizedCollection<E>
implements Collection<T> { implements Collection<E> {
Collection<T> c; // Backing Collection Collection<E> c; // Backing Collection
Object mutex; // Object on which to synchronize Object mutex; // Object on which to synchronize
SynchronizedCollection(Collection<T> c) { SynchronizedCollection(Collection<E> c) {
if (c==null) if (c==null)
throw new NullPointerException(); throw new NullPointerException();
this.c = c; this.c = c;
mutex = this; mutex = this;
} }
SynchronizedCollection(Collection<T> c, Object mutex) { SynchronizedCollection(Collection<E> c, Object mutex) {
this.c = c; this.c = c;
this.mutex = mutex; this.mutex = mutex;
} }
@@ -458,11 +458,11 @@ public class Collections
synchronized(mutex) {return c.toArray(a);} synchronized(mutex) {return c.toArray(a);}
} }
public Iterator<T> iterator() { public Iterator<E> iterator() {
return c.iterator(); // Must be manually synched by user! return c.iterator(); // Must be manually synched by user!
} }
public boolean add(T o) { public boolean add(E o) {
synchronized(mutex) {return c.add(o);} synchronized(mutex) {return c.add(o);}
} }
public boolean remove(Object o) { public boolean remove(Object o) {
@@ -472,7 +472,7 @@ public class Collections
public boolean containsAll(Collection<?> coll) { public boolean containsAll(Collection<?> coll) {
synchronized(mutex) {return c.containsAll(coll);} synchronized(mutex) {return c.containsAll(coll);}
} }
public boolean addAll(Collection<? extends T> coll) { public boolean addAll(Collection<? extends E> coll) {
synchronized(mutex) {return c.addAll(coll);} synchronized(mutex) {return c.addAll(coll);}
} }
public boolean removeAll(Collection<?> coll) { public boolean removeAll(Collection<?> coll) {
@@ -191,26 +191,26 @@ public class CountHashMap<K> extends HashMap<K, int[]>
protected Map.Entry<K, int[]> _entry; protected Map.Entry<K, int[]> _entry;
} }
protected class CountEntrySet<K> protected class CountEntrySet<E>
extends AbstractSet<Entry<K>> extends AbstractSet<Entry<E>>
{ {
public CountEntrySet (Set<Map.Entry<K,int[]>> superset) public CountEntrySet (Set<Map.Entry<E,int[]>> superset)
{ {
_superset = superset; _superset = superset;
} }
public Iterator<Entry<K>> iterator () public Iterator<Entry<E>> iterator ()
{ {
final Iterator<Map.Entry<K, int[]>> itr = _superset.iterator(); final Iterator<Map.Entry<E, int[]>> itr = _superset.iterator();
return new Iterator<Entry<K>>() { return new Iterator<Entry<E>>() {
public boolean hasNext () public boolean hasNext ()
{ {
return itr.hasNext(); return itr.hasNext();
} }
public Entry<K> next () public Entry<E> next ()
{ {
return new CountEntryImpl<K>(itr.next()); return new CountEntryImpl<E>(itr.next());
} }
public void remove () public void remove ()
@@ -240,6 +240,6 @@ public class CountHashMap<K> extends HashMap<K, int[]>
CountHashMap.this.clear(); CountHashMap.this.clear();
} }
protected Set<Map.Entry<K,int[]>> _superset; protected Set<Map.Entry<E,int[]>> _superset;
} }
} }