Added an unbox() method that take an Integer collection.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2541 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
samskivert
2009-03-25 23:37:06 +00:00
parent 0629367932
commit 830cf8de5c
@@ -21,6 +21,7 @@
package com.samskivert.util;
import java.util.Arrays;
import java.util.Collection;
/**
* This class manages arrays of ints. Some of those routines mimic the
@@ -518,6 +519,22 @@ public class IntListUtil
return unboxed;
}
/**
* Converts an array of Integer objects to an array of primitives.
*/
public static int[] unbox (Collection<Integer> list)
{
if (list == null) {
return null;
}
int[] unboxed = new int[list.size()];
int ii = 0;
for (Integer value : list) {
unboxed[ii++] = value;
}
return unboxed;
}
/**
* The size of a list to create if we have to create one entirely
* from scratch rather than just expand it.