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

Method compareTo

lib/java/nio/ShortBuffer.java:179–196  ·  view source on GitHub ↗

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

(ShortBuffer otherBuffer)

Source from the content-addressed store, hash-verified

177 * if {@code otherBuffer} is not a short buffer.
178 */
179 public int compareTo(ShortBuffer otherBuffer) {
180 int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
181 : otherBuffer.remaining();
182 int thisPos = position;
183 int otherPos = otherBuffer.position;
184 short thisByte, otherByte;
185 while (compareRemaining > 0) {
186 thisByte = get(thisPos);
187 otherByte = otherBuffer.get(otherPos);
188 if (thisByte != otherByte) {
189 return thisByte < otherByte ? -1 : 1;
190 }
191 thisPos++;
192 otherPos++;
193 compareRemaining--;
194 }
195 return remaining() - otherBuffer.remaining();
196 }
197
198 /**
199 * 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