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

(coll spec) Arrays.binarySearch() says list.size() when it should say a.length

XMLWordPrintable

      Name: gm110360 Date: 05/19/2003


      A DESCRIPTION OF THE PROBLEM :
      The error appears to be repeted in the entire family of binarySearch() family of methods.

      It looks like a cut and past error from Collections.binarySearch().

      References to list should be changed to array and the corresponding list.size() should be a.length


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Returns:
          index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length, if all elements in the list are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
      ACTUAL -
      Returns:
          index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the list: the index of the first element greater than the key, or list.size(), if all elements in the list are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.

      URL OF FAULTY DOCUMENTATION :
      http://java.sun.com/j2se/1.4.1/docs/api/java/util/Arrays.html#binarySearch(byte[],%20byte)
      (Review ID: 185819)
      ======================================================================

            martin Martin Buchholz
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: