From 830cf8de5cb77df5a99bb8fa67e33d890b5195ca Mon Sep 17 00:00:00 2001 From: samskivert Date: Wed, 25 Mar 2009 23:37:06 +0000 Subject: [PATCH] Added an unbox() method that take an Integer collection. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2541 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/IntListUtil.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/java/com/samskivert/util/IntListUtil.java b/src/java/com/samskivert/util/IntListUtil.java index d80d5dc8..b07dd4d7 100644 --- a/src/java/com/samskivert/util/IntListUtil.java +++ b/src/java/com/samskivert/util/IntListUtil.java @@ -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 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.