Author: hlship
Date: Sun Feb 11 12:06:19 2007
New Revision: 506111
URL: http://svn.apache.org/viewvc?view=rev&rev=506111
Log:
Allow the initial size of the Stack's array to be specified.
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/Stack.java
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/Stack.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/Stack.java?view=diff&rev=506111&r1=506110&r2=506111
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/Stack.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/Stack.java
Sun Feb 11 12:06:19 2007
@@ -26,15 +26,30 @@
*/
public class Stack<E>
{
+ private static final int MINIMUM_SIZE = 3;
+
private static final int DEFAULT_ARRAY_SIZE = 20;
private Object[] _items;
private int _index = -1;
+ /**
+ * Normal constructor supporting an initial size of 20.
+ */
public Stack()
{
- _items = new Object[DEFAULT_ARRAY_SIZE];
+ this(DEFAULT_ARRAY_SIZE);
+ }
+
+ /**
+ * @param initialSize
+ * the initial size of the internal array (which will be
expanded as necessary). For
+ * best efficiency, set this to the maximum depth of the stack.
+ */
+ public Stack(int initialSize)
+ {
+ _items = new Object[Math.max(initialSize, MINIMUM_SIZE)];
}
/** Returns true if the stack is empty. */