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

(coll) Create a standard Pair class (based on C++ pair class)

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description



      Name: rmT116609 Date: 10/31/2003


      A DESCRIPTION OF THE REQUEST :
      A standard pair class would assist developers who constantly write such helper classes.

      JUSTIFICATION :
      This class is simple to write and would go a long way towards making code more readable as we would not so many little classes which are all 99% the same. Also, could be the base class for other objects and replace Map.Entry which in my opinion should have been an immutable Pair object which would have simplified writing Map implementations, i.e. having an actual class instead of having to re-implement (which while easy is tiresome).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would like pair classes that are mutable, immutable & thread-safe. I would also like second parameters to be optiunal based on either an inheritance model or something else. I also would like a pair that supports the Comparable interface. Note that equals(), hashCode() and toString() should be overridden and implemented to handle first and second.
      ACTUAL -
      Pair p = new Pair(new Integer(3), "abcde");
      p.getFirst();
      p.getSecond();
      p.toString();

      CUSTOMER SUBMITTED WORKAROUND :
      I wrote my own pair class.

      Pair - optional second
      StrictPair - second required
      MutablePair - mutable
      ComparablePair - first and second are comparable and non-null
      ThreadsafePair - mutable and thread-safe
      (Incident Review ID: 218844)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: