Checks whether this double buffer is equal to another object. If other is not a DoubleBuffer then false is returned. Two double buffers are equal if their remaining doubles are equal. Position, limit, capacity and mark are not considered. This method considers two dou
(Object other)
| 229 | * {@code false} otherwise. |
| 230 | */ |
| 231 | @Override |
| 232 | public boolean equals(Object other) { |
| 233 | if (!(other instanceof DoubleBuffer)) { |
| 234 | return false; |
| 235 | } |
| 236 | DoubleBuffer otherBuffer = (DoubleBuffer) other; |
| 237 | |
| 238 | if (remaining() != otherBuffer.remaining()) { |
| 239 | return false; |
| 240 | } |
| 241 | |
| 242 | int myPosition = position; |
| 243 | int otherPosition = otherBuffer.position; |
| 244 | boolean equalSoFar = true; |
| 245 | while (equalSoFar && (myPosition < limit)) { |
| 246 | double a = get(myPosition++); |
| 247 | double b = otherBuffer.get(otherPosition++); |
| 248 | equalSoFar = a == b || (a != a && b != b); |
| 249 | } |
| 250 | |
| 251 | return equalSoFar; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Returns the double at the current position and increases the position by |