2004-05-04 Michael Koch <konqueror@gmx.de>
* java/nio/ByteBuffer.java, java/nio/CharBuffer.java, java/nio/DoubleBuffer.java, java/nio/FloatBuffer.java, java/nio/IntBuffer.java, java/nio/LongBuffer.java, java/nio/ShortBuffer.java: (compareTo): Fixed bogus implementation in all buffer classes. From-SVN: r81489
This commit is contained in:
parent
6c89c39a48
commit
933522fbc3
8 changed files with 143 additions and 167 deletions
|
@ -1,5 +1,5 @@
|
|||
/* IntBuffer.java --
|
||||
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -265,32 +265,27 @@ public abstract class IntBuffer extends Buffer
|
|||
*/
|
||||
public int compareTo (Object obj)
|
||||
{
|
||||
IntBuffer a = (IntBuffer) obj;
|
||||
IntBuffer other = (IntBuffer) obj;
|
||||
|
||||
if (a.remaining () != remaining ())
|
||||
return 1;
|
||||
|
||||
if (! hasArray () ||
|
||||
! a.hasArray ())
|
||||
int num = Math.min(remaining(), other.remaining());
|
||||
int pos_this = position();
|
||||
int pos_other = other.position();
|
||||
|
||||
for (int count = 0; count < num; count++)
|
||||
{
|
||||
return 1;
|
||||
int a = get(pos_this++);
|
||||
int b = other.get(pos_other++);
|
||||
|
||||
if (a == b)
|
||||
continue;
|
||||
|
||||
if (a < b)
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int r = remaining ();
|
||||
int i1 = position ();
|
||||
int i2 = a.position ();
|
||||
|
||||
for (int i = 0; i < r; i++)
|
||||
{
|
||||
int t = (int) (get (i1) - a.get (i2));
|
||||
|
||||
if (t != 0)
|
||||
{
|
||||
return (int) t;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
return remaining() - other.remaining();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue