Wow, the signatures on these were way wrong. Let's fix them and break
binary compatibilty! Whee! I genericized these when I was first using generics, before I understood the "PECS" rule. It seems to me that these could be <T> Collection<T> addAll (Collection<T> col, Iterator<? extends T> iter); (rather than) <T> Collection<? super T> addAll (Collection<? super T> col, Iterator<T> iter); ..but in fact there is already a java.util.Collections.addAll() that takes an array and specifies the type as that of the producer. So I followed that. I'm not sure which would be more correct. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2646 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -37,8 +37,7 @@ public class CollectionUtil
|
||||
* Adds all items returned by the enumeration to the supplied collection
|
||||
* and returns the supplied collection.
|
||||
*/
|
||||
public static <E, T extends Collection<E>> T addAll (
|
||||
T col, Enumeration<E> enm)
|
||||
public static <T> Collection<? super T> addAll (Collection<? super T> col, Enumeration<T> enm)
|
||||
{
|
||||
while (enm.hasMoreElements()) {
|
||||
col.add(enm.nextElement());
|
||||
@@ -50,8 +49,7 @@ public class CollectionUtil
|
||||
* Adds all items returned by the iterator to the supplied collection and
|
||||
* returns the supplied collection.
|
||||
*/
|
||||
public static <E, T extends Collection<E>> T addAll (
|
||||
T col, Iterator<E> iter)
|
||||
public static <T> Collection<? super T> addAll (Collection<? super T> col, Iterator<T> iter)
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
col.add(iter.next());
|
||||
@@ -64,10 +62,10 @@ public class CollectionUtil
|
||||
* returns the supplied collection. If the supplied array is null, nothing
|
||||
* is added to the collection.
|
||||
*/
|
||||
public static <E, T extends Collection<E>> T addAll (T col, E[] values)
|
||||
public static <T> Collection<? super T> addAll (Collection<? super T> col, T[] values)
|
||||
{
|
||||
if (values != null) {
|
||||
for (E value : values) {
|
||||
for (T value : values) {
|
||||
col.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user