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

(coll) Add Bag implementations (unordered Collection allowing duplicates)

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      A DESCRIPTION OF THE REQUEST :
      There are no current direct implementations of java.util.Collection that feature no maintenance of order and that allow duplicates. A direct implementation of such a collection would be beneficial, as possibly would the identification of the interface java.util.Bag extends java.util.Collection that counts duplicates.

      Apache already offers such implementations, and it would be nice to have them as a standard part of the JDK.

      JUSTIFICATION :
      Current users of JDK-only collection classes are forced to implement their own Bags, or suffer the performance consequences of order maintenance or uniqueness when that behavior is not needed.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Performant Bag implementations.

      ACTUAL -
      None.


      ---------- BEGIN SOURCE ----------
      import java.util.Bag;

      ...
      Bag bag = new java.util.HashBag();
      Foo foo = new Foo();
      int count = 5;
      for (int i = 0; i < count; i++) {
        bag.add(foo);
      }
      assert count == bag.getCountOf(foo);

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Extend list, adding behavior that counts occurrences of elements and offers methods to get the count of elements, enduring performance penalty of maintaining order.
      ###@###.### 2004-12-09 22:45:52 GMT

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: