MCPcopy Create free account
hub / github.com/davidgiven/luje / compareTo

Method compareTo

lib/java/nio/DoubleBuffer.java:178–197  ·  view source on GitHub ↗

Compare the remaining doubles of this buffer to another double buffer's remaining doubles. @param otherBuffer another double buffer. @return a negative value if this is less than other; 0 if this equals to other; a positive value if this is greater than {@

(DoubleBuffer otherBuffer)

Source from the content-addressed store, hash-verified

176 * if {@code other} is not a double buffer.
177 */
178 public int compareTo(DoubleBuffer otherBuffer) {
179 int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
180 : otherBuffer.remaining();
181 int thisPos = position;
182 int otherPos = otherBuffer.position;
183 double thisDouble, otherDouble;
184 while (compareRemaining > 0) {
185 thisDouble = get(thisPos);
186 otherDouble = otherBuffer.get(otherPos);
187 // checks for double and NaN inequality
188 if ((thisDouble != otherDouble)
189 && ((thisDouble == thisDouble) || (otherDouble == otherDouble))) {
190 return thisDouble < otherDouble ? -1 : 1;
191 }
192 thisPos++;
193 otherPos++;
194 compareRemaining--;
195 }
196 return remaining() - otherBuffer.remaining();
197 }
198
199 /**
200 * Returns a duplicated buffer that shares its content with this buffer.

Callers

nothing calls this directly

Calls 3

getMethod · 0.95
remainingMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected