Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-704

GrowthList: ambiguity in constructor argument

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.0, 4.2
    • Fix Version/s: 4.5
    • Component/s: List
    • Labels:
      None

      Description

      The javadoc of constructor

      GrowthList(int initialSize)

      states:

      initialSize - the initial size of the ArrayList

       

      However, this is confusing terminology: As the initialSize argument is passed directly to the internal ArrayList constructor, this is effectively the initial capacity. The capacity is NOT the same as the actual list size. So after this constructor is called, the actual list.size() is still 0. This is identical to the normal ArrayList constructor's behavior of course.

      However, the GrowthList javadoc is confusing by explicitly claiming this is the "initial size", which may lead the reader to think that this constructor effectively grows the initial list to an actual given size - size in the sense the word is used everywhere else in the javadoc of this class. As opposed to the javadoc of Java's ArrayList, where they clear use the terminology "the initial capacity of the list", to avoid any confusion between the notion of internal array capacity and the list size.

      If, long ago, this GrowthList constructor was once intended to really set the ini**tial size, then is clearly not what the code does.

      However, if this never was the intention, and this was just intended to be an initial capacity, as the normal ArrayList, then the javadoc of GrowthList should be slightly reworded, to avoid ambiguity or misunderstanding, and make clear this is just the initial capacity of the underlying ArrayList; not the initial size of the list.

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                belpk K P
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m