/** * Returns the current hash code of this buffer. * * <p> The hash code of a byte buffer depends only upon its remaining * elements; that is, upon the elements from <tt>position()</tt> up to, and * including, the element at <tt>limit()</tt> - <tt>1</tt>. * * <p> Because buffer hash codes are content-dependent, it is inadvisable * to use buffers as keys in hash maps or similar data structures unless it * is known that their contents will not change. </p> * * @return The current hash code of this buffer */ @Override public int hashCode() { int h = 1; int p = position(); for (int i = limit() - 1; i >= p; i--) h = 31 * h + (int) get(i); h = 31 * h + mark; return h; }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public int compareTo(Buffer that) { checkDispose(); int n = this.position() + Math.min(this.remaining(), that.remaining()); for (int i = this.position(), j = that.position(); i < n; i++, j++) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 == v2) continue; if (v1 < v2) return -1; return +1; } return this.remaining() - that.remaining(); }
@Override public boolean equals(Object obj) { if (obj instanceof Buffer) { Buffer that = (Buffer) obj; if (this.remaining() != that.remaining()) { return false; } int p = this.position(); for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 != v2) { return false; } } return true; } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof Buffer) { Buffer that = (Buffer) obj; if (this.remaining() != that.remaining()) { return false; } int p = this.position(); for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 != v2) { return false; } } return true; } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof Buffer) { Buffer that = (Buffer) obj; if (this.remaining() != that.remaining()) { return false; } int p = this.position(); for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 != v2) { return false; } } return true; } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof Buffer) { Buffer that = (Buffer) obj; if (this.remaining() != that.remaining()) { return false; } int p = this.position(); for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 != v2) { return false; } } return true; } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof Buffer) { Buffer that = (Buffer) obj; if (this.remaining() != that.remaining()) { return false; } int p = this.position(); for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 != v2) { return false; } } return true; } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof Buffer) { Buffer that = (Buffer) obj; if (this.remaining() != that.remaining()) { return false; } int p = this.position(); for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 != v2) { return false; } } return true; } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof Buffer) { Buffer that = (Buffer) obj; if (this.remaining() != that.remaining()) { return false; } int p = this.position(); for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) { byte v1 = this.get(i); byte v2 = that.get(j); if (v1 != v2) { return false; } } return true; } return false; }