コード例 #1
0
 /**
  * Compares this buffer to another.
  *
  * <p>Two float buffers are compared by comparing their sequences of remaining elements
  * lexicographically, without regard to the starting position of each sequence within its
  * corresponding buffer.
  *
  * <p>Pairs of {@code float} elements are compared as if by invoking {@link
  * Float#compare(float,float)}, except that {@code -0.0} and {@code 0.0} are considered to be
  * equal. {@code Float.NaN} is considered by this method to be equal to itself and greater than
  * all other {@code float} values (including {@code Float.POSITIVE_INFINITY}).
  *
  * <p>A float buffer is not comparable to any other type of object.
  *
  * @return A negative integer, zero, or a positive integer as this buffer is less than, equal to,
  *     or greater than the given buffer
  */
 public int compareTo(FloatBuffer that) {
   int n = this.position() + Math.min(this.remaining(), that.remaining());
   for (int i = this.position(), j = that.position(); i < n; i++, j++) {
     int cmp = compare(this.get(i), that.get(j));
     if (cmp != 0) return cmp;
   }
   return this.remaining() - that.remaining();
 }