From 1b040377404e496235027399af32c359ee2ac9c2 Mon Sep 17 00:00:00 2001 From: mdb Date: Tue, 21 Nov 2006 01:06:49 +0000 Subject: [PATCH] A jab to the left, a jab to the right, next thing you know you're boxing. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1980 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/IntListUtil.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/java/com/samskivert/util/IntListUtil.java b/src/java/com/samskivert/util/IntListUtil.java index 564d22b6..dc855d0c 100644 --- a/src/java/com/samskivert/util/IntListUtil.java +++ b/src/java/com/samskivert/util/IntListUtil.java @@ -483,6 +483,36 @@ public class IntListUtil return newlist; } + /** + * Covnerts an array of primitives to an array of objects. + */ + public static Integer[] box (int[] list) + { + if (list == null) { + return null; + } + Integer[] boxed = new Integer[list.length]; + for (int ii = 0; ii < list.length; ii++) { + boxed[ii] = list[ii]; + } + return boxed; + } + + /** + * Converts an array of Integer objects to an array of primitives. + */ + public static int[] unbox (Integer[] list) + { + if (list == null) { + return null; + } + int[] unboxed = new int[list.length]; + for (int ii = 0; ii < list.length; ii++) { + unboxed[ii] = list[ii]; + } + return unboxed; + } + /** * The size of a list to create if we have to create one entirely * from scratch rather than just expand it.