Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5098155

(coll) Need "VariableCapacity" interface for ensureCapacity, trimToSize apis

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description



      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.

      JUSTIFICATION :
      This enhancement provides a means to recognize common functionality among collections and buffers that maintain an internal capacity.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      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

      or

      2. Use reflection to see if a collection or buffer has the ensureCapacity and trimToSize operations.
      (Incident Review ID: 302226)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                smarks Stuart Marks
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: