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

(coll) support for set like behavior of java.util.List

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Won't Fix
    • P4
    • None
    • 1.2.0
    • core-libs

    Description



      Name: diC59631 Date: 06/26/98


      In the comments preceeding the List interface one can find
      the following:

      It is not inconceivable that someone might wish to implement a List that prohibits
      duplicates,

      This conceivable :) case would be very useful in our application
      though there is one little problem. All methods, such as add()
      addAll, remove(), removeAll, retainAll, etc. return a boolean value
      to indicate if the underlying collection has been modified or not.
      All but one: add(int, Object). This one returns void. As a consequence
      we have two choices: either quietly ignore duplicates, or throw a runtime
      exception. A preferred, though not valid option, would be to return
      the index to the location where the element has been either added
      or found. Thus if, say add(4, "Hello") returns 4 we know that
      there is no duplicate and the element has been added successfully.
      On the other hand if add(4, "Hello") returns, say, 11, we know that
      this object was already in the list and is located at position 11. To
      put it shortly, could you please change the signature of the add(int, Object)
      method to:

      int add(int index, Object element)

      Thanks in advance!
      (Review ID: 34375)
      ======================================================================

      Attachments

        Activity

          People

            Unassigned Unassigned
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: