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

Method equals

lib/java/nio/ByteBuffer.java:351–370  ·  view source on GitHub ↗

Checks whether this byte buffer is equal to another object. If other is not a byte buffer then false is returned. Two byte buffers are equal if and only if their remaining bytes are exactly the same. Position, limit, capacity and mark are not considered. @param other

(Object other)

Source from the content-addressed store, hash-verified

349 * {@code false} otherwise.
350 */
351 @Override
352 public boolean equals(Object other) {
353 if (!(other instanceof ByteBuffer)) {
354 return false;
355 }
356 ByteBuffer otherBuffer = (ByteBuffer) other;
357
358 if (remaining() != otherBuffer.remaining()) {
359 return false;
360 }
361
362 int myPosition = position;
363 int otherPosition = otherBuffer.position;
364 boolean equalSoFar = true;
365 while (equalSoFar && (myPosition < limit)) {
366 equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++);
367 }
368
369 return equalSoFar;
370 }
371
372 /**
373 * Returns the byte at the current position and increases the position by 1.

Callers

nothing calls this directly

Calls 2

getMethod · 0.95
remainingMethod · 0.80

Tested by

no test coverage detected