summaryrefslogtreecommitdiff
path: root/java/util
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2007-01-20 02:08:31 +0000
committerTom Tromey <tromey@redhat.com>2007-01-20 02:08:31 +0000
commitcad5d09e58807c3ee790c335161a7d557d68110d (patch)
treefc23d3bc4c2e3074c2c739eb9945e507776e731d /java/util
parent883bc2d2370334cf3b1cbb183c596319c54e031a (diff)
downloadclasspath-cad5d09e58807c3ee790c335161a7d557d68110d.tar.gz
2007-01-19 Marco Trudel <mtrudel@gmx.ch>
* java/util/Arrays.java (binarySearch): Change comparison order.
Diffstat (limited to 'java/util')
-rw-r--r--java/util/Arrays.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/java/util/Arrays.java b/java/util/Arrays.java
index 3574ba1c6..8f7049377 100644
--- a/java/util/Arrays.java
+++ b/java/util/Arrays.java
@@ -1,5 +1,5 @@
/* Arrays.java -- Utility class with methods to operate on arrays
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -639,10 +639,13 @@ public class Arrays
while (low <= hi)
{
mid = (low + hi) >>> 1;
- final int d = Collections.compare(key, a[mid], c);
+ // NOTE: Please keep the order of a[mid] and key. Although
+ // not required by the specs, the RI has it in this order as
+ // well, and real programs (erroneously) depend on it.
+ final int d = Collections.compare(a[mid], key, c);
if (d == 0)
return mid;
- else if (d < 0)
+ else if (d > 0)
hi = mid - 1;
else
// This gets the insertion point right on the last loop