Comment pedantry.
Considered adding a note that toArray() is generally not safe, but the Collections run through here in normal depot usage will be safe to use. Check out the implementation of AbstractCollection's toArray(T[]).
This commit is contained in:
@@ -65,6 +65,7 @@ public abstract class Sequence<T> implements Iterable<T>
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
// In a perfect world this would be <S super T> S[] toArray (Class<S> clazz)
|
||||||
public T[] toArray (Class<T> clazz) {
|
public T[] toArray (Class<T> clazz) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
T[] array = (T[]) Array.newInstance(clazz, source.size());
|
T[] array = (T[]) Array.newInstance(clazz, source.size());
|
||||||
@@ -91,13 +92,13 @@ public abstract class Sequence<T> implements Iterable<T>
|
|||||||
public abstract boolean isEmpty ();
|
public abstract boolean isEmpty ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts this sequence into an array list.
|
* Converts this sequence into an ArrayList.
|
||||||
*/
|
*/
|
||||||
public abstract ArrayList<T> toList ();
|
public abstract ArrayList<T> toList ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts this sequence into an array.
|
* Converts this sequence into an array.
|
||||||
* I wish this were <S super T> S[] toArray (Class<S? clazz);
|
* I wish this were <S super T> S[] toArray (Class<?> clazz);
|
||||||
*/
|
*/
|
||||||
public abstract T[] toArray (Class<T> clazz);
|
public abstract T[] toArray (Class<T> clazz);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user