Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956.

Also see the following revisions:

    ------------------------------------------------------------------------
    r471192 | scolebourne | 2006-11-04 06:04:46 -0800 (Sat, 04 Nov 2006) | 1 line
    
    Remove getList() - use decorated()
    ------------------------------------------------------------------------


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2009-09-15 05:55:39 +00:00
parent 936ba654ac
commit 23c5be297b
1 changed files with 18 additions and 18 deletions

View File

@ -55,7 +55,7 @@ import java.util.List;
* @author Stephen Colebourne
* @author Paul Legato
*/
public class GrowthList extends AbstractSerializableListDecorator {
public class GrowthList<E> extends AbstractSerializableListDecorator<E> {
/** Serialization version */
private static final long serialVersionUID = -3620001881672L;
@ -66,8 +66,8 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
public static List decorate(List list) {
return new GrowthList(list);
public static <E> List<E> decorate(List<E> list) {
return new GrowthList<E>(list);
}
//-----------------------------------------------------------------------
@ -75,7 +75,7 @@ public class GrowthList extends AbstractSerializableListDecorator {
* Constructor that uses an ArrayList internally.
*/
public GrowthList() {
super(new ArrayList());
super(new ArrayList<E>());
}
/**
@ -85,7 +85,7 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @throws IllegalArgumentException if initial size is invalid
*/
public GrowthList(int initialSize) {
super(new ArrayList(initialSize));
super(new ArrayList<E>(initialSize));
}
/**
@ -94,7 +94,7 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
protected GrowthList(List list) {
protected GrowthList(List<E> list) {
super(list);
}
@ -117,12 +117,12 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @throws ClassCastException if the underlying list rejects the element
* @throws IllegalArgumentException if the underlying list rejects the element
*/
public void add(int index, Object element) {
int size = getList().size();
public void add(int index, E element) {
int size = decorated().size();
if (index > size) {
getList().addAll(Collections.nCopies(index - size, null));
decorated().addAll(Collections.<E>nCopies(index - size, null));
}
getList().add(index, element);
decorated().add(index, element);
}
//-----------------------------------------------------------------------
@ -145,14 +145,14 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @throws ClassCastException if the underlying list rejects the element
* @throws IllegalArgumentException if the underlying list rejects the element
*/
public boolean addAll(int index, Collection coll) {
int size = getList().size();
public boolean addAll(int index, Collection<? extends E> coll) {
int size = decorated().size();
boolean result = false;
if (index > size) {
getList().addAll(Collections.nCopies(index - size, null));
decorated().addAll(Collections.<E>nCopies(index - size, null));
result = true;
}
return (getList().addAll(index, coll) | result);
return (decorated().addAll(index, coll) | result);
}
//-----------------------------------------------------------------------
@ -175,12 +175,12 @@ public class GrowthList extends AbstractSerializableListDecorator {
* @throws ClassCastException if the underlying list rejects the element
* @throws IllegalArgumentException if the underlying list rejects the element
*/
public Object set(int index, Object element) {
int size = getList().size();
public E set(int index, E element) {
int size = decorated().size();
if (index >= size) {
getList().addAll(Collections.nCopies((index - size) + 1, null));
decorated().addAll(Collections.<E>nCopies((index - size) + 1, null));
}
return getList().set(index, element);
return decorated().set(index, element);
}
}