1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

support ToArray(int[])

This commit is contained in:
Kevin Glynn 2011-02-03 14:16:29 +01:00
parent 283d0d4d7a
commit 5e3dc6d5a0
2 changed files with 34 additions and 11 deletions

View File

@ -109,8 +109,10 @@
<Return>System.Void</Return>
</Method>
<Method>
<Imports />
<Java>${this:16}.toArray(new ${TYPEOF_expr_TYPE}[0])</Java>
<Imports>
<Import>RusticiSoftware.System.Collections.ArrayListSupport</Import>
</Imports>
<Java>ArrayListSupport.toArray(${this}, new ${TYPEOF_expr_TYPE}[0])</Java>
<Params>
<Param>
<Type>System.Type</Type>

View File

@ -84,15 +84,36 @@ public class ArrayListSupport extends AbstractCollection implements List {
return (T[]) al.toArray(dummy);
}
public int[] toArrayS(int[] dummy)
{
int idx = 0;
int[] arrayInt = new int[al.size()];
for(int v : (ArrayList<Integer>)al)
arrayInt[idx++] = v;
return arrayInt;
}
public int[] toArrayS(int[] dummy)
{
int idx = 0;
int[] arrayInt = new int[al.size()];
for(int v : (ArrayList<Integer>)al)
arrayInt[idx++] = v;
return arrayInt;
}
// public static Object[] toArray(ArrayList al)
// {
// int idx = 0;
// Object[] arr = new Object[al.size()];
// for(Object v : al)
// arr[idx++] = v;
// return arr;
// }
public static <T> T[] toArray(ArrayList al, T[] dummy)
{
return (T[]) al.toArray(dummy);
}
public static int[] toArray(ArrayList al, int[] dummy)
{
int idx = 0;
int[] arrayInt = new int[al.size()];
for(int v : (ArrayList<Integer>)al)
arrayInt[idx++] = v;
return arrayInt;
}
public Object[] toArray()
{
return al.toArray();