From cbdff2c8836cd6e2a02651cf4651bcbbd8d8d110 Mon Sep 17 00:00:00 2001 From: ray Date: Thu, 27 Nov 2003 02:10:34 +0000 Subject: [PATCH] Added a constructor with which you can specify the initial capacity. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1329 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/ArrayIntSet.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java b/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java index cb7f5aaa..28c34b87 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.14 2003/06/24 22:55:38 mdb Exp $ +// $Id: ArrayIntSet.java,v 1.15 2003/11/27 02:10:34 ray Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -40,14 +40,24 @@ public class ArrayIntSet extends AbstractSet */ public ArrayIntSet (int[] values) { + this(values.length); add(values); } /** - * Constructs an empty set. + * Construct an ArrayIntSet of the specified initial capacity. + */ + public ArrayIntSet (int initialCapacity) + { + _values = new int[initialCapacity]; + } + + /** + * Constructs an empty set with the default initial capacity. */ public ArrayIntSet () { + this(16); } // documentation inherited from interface @@ -398,7 +408,7 @@ public class ArrayIntSet extends AbstractSet } /** An array containing the values in this set. */ - protected int[] _values = new int[16]; + protected int[] _values; /** The number of elements in this set. */ protected int _size;