Name: rmT116609 Date: 09/07/2004
A DESCRIPTION OF THE REQUEST :
In my project, I work with several various collections and buffers. When preparing to make numerous additions to these objects, I wish to invoke the "ensureCapacity" operation on those objects that support it in order to avoid numerous incremental memory allocations and recopying during the addition operations.
It would be nice to have a common interface for objects that provide the ability to increase or decrease the capacity of underlying arrays.
This enhancement provides a means to recognize common functionality among collections and buffers that maintain an internal capacity.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would like to be able to access an interface similar to the following
public interface VariableCapacity
public void ensureCapacity(int minCapacity);
public void trimToSize();
CUSTOMER SUBMITTED WORKAROUND :
1. Perform instanceof checks for each class known to provide the ensureCapacity and trimToSize operations
2. Use reflection to see if a collection or buffer has the ensureCapacity and trimToSize operations.
(Incident Review ID: 302226)