* @param newLength Length of the copy to be returned.
* @return A new array consisting of the elements specified.
*/
- @SuppressWarnings("unchecked")
private static <E> E[] copyOf(final E[] array, int newLength) {
E[] result = (E[])Array.newInstance(array.getClass().getComponentType(), newLength); // Is it useful to use newInstance?
System.arraycopy(array, 0, result, 0, Math.min(array.length, newLength));
* @param newType Type of the array to be returned.
* @return A new array consisting of the elements specified.
*/
- @SuppressWarnings("unchecked")
private static <E, U> E[] copyOf(final U[] array, int newLength, Class<? extends E[]> newType) {
E[] result = (E[])Array.newInstance(newType.getComponentType(), newLength);
System.arraycopy(array, 0, result, 0, Math.min(array.length, newLength));
* @param end Ending position of the range, exclusive.
* @return A new array consisting of the elements specified. The length of the new array is equal to end-start
*/
- @SuppressWarnings("unchecked")
private static <E> E[] copyOfRange(final E[] array, int start, int end) {
E[] result = (E[])Array.newInstance(array.getClass().getComponentType(), end - start);
System.arraycopy(array, start, result, 0, end - start);
* @see java.util.AbstractCollection#toArray(T[])
*/
@Override
- @SuppressWarnings("unchecked")
public <E> E[] toArray(E[] array)
{
if(array.length < fArray.length) {