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

Method compareTo

lib/java/nio/CharBuffer.java:248–265  ·  view source on GitHub ↗

Compare the remaining chars of this buffer to another char buffer's remaining chars. @param otherBuffer another char buffer. @return a negative value if this is less than otherBuffer; 0 if this equals to otherBuffer; a positive value if this is greater tha

(CharBuffer otherBuffer)

Source from the content-addressed store, hash-verified

246 * if {@code otherBuffer} is not a char buffer.
247 */
248 public int compareTo(CharBuffer otherBuffer) {
249 int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
250 : otherBuffer.remaining();
251 int thisPos = position;
252 int otherPos = otherBuffer.position;
253 char thisByte, otherByte;
254 while (compareRemaining > 0) {
255 thisByte = get(thisPos);
256 otherByte = otherBuffer.get(otherPos);
257 if (thisByte != otherByte) {
258 return thisByte < otherByte ? -1 : 1;
259 }
260 thisPos++;
261 otherPos++;
262 compareRemaining--;
263 }
264 return remaining() - otherBuffer.remaining();
265 }
266
267 /**
268 * 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