From 3fed034271ca0ff6f8486eb0fc75652decae1174 Mon Sep 17 00:00:00 2001 From: mdb Date: Tue, 4 Mar 2003 19:05:43 +0000 Subject: [PATCH] Added toShortArray(). git-svn-id: https://samskivert.googlecode.com/svn/trunk@1061 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/ArrayIntSet.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java b/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java index 0419671e..4ec3d5f1 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java +++ b/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java @@ -1,5 +1,5 @@ // -// $Id: ArrayIntSet.java,v 1.11 2003/01/31 02:27:48 mdb Exp $ +// $Id: ArrayIntSet.java,v 1.12 2003/03/04 19:05:43 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -131,6 +131,20 @@ public class ArrayIntSet extends AbstractSet return target; } + /** + * Creates an array of shorts from the contents of this set. Any + * values outside the range of a short will be truncated by way of a + * cast. + */ + public short[] toShortArray () + { + short[] values = new short[_size]; + for (int ii = 0; ii < _size; ii++) { + values[ii] = (short)_values[ii]; + } + return values; + } + // documentation inherited from interface public boolean add (Object o) {