/** * Returns the hash code for the specified subsequence of the given {@code boolean} array. * * <p>Default implementation delegates to {@link #hash(Object, Access, long, long)} method * using {@linkplain Access#unsafe() unsafe} {@code Access}. * * @param input the array to read data from * @param off index of the first {@code boolean} in the subsequence to hash * @param len length of the subsequence to hash * @return hash code for the specified subsequence * @throws IndexOutOfBoundsException if {@code off < 0} or {@code off + len > input.length} * or {@code len < 0} */ public long hashBooleans(@NotNull boolean[] input, int off, int len) { checkArrayOffs(input.length, off, len); return unsafeHash(input, BOOLEAN_BASE + off, len); }
/** * Returns the hash code for the specified subsequence of the given {@code byte} array. * * <p>Default implementation delegates to {@link #hash(Object, Access, long, long)} method * using {@linkplain Access#unsafe() unsafe} {@code Access}. * * @param input the array to read bytes from * @param off index of the first {@code byte} in the subsequence to hash * @param len length of the subsequence to hash * @return hash code for the specified subsequence * @throws IndexOutOfBoundsException if {@code off < 0} or {@code off + len > input.length} * or {@code len < 0} */ public long hashBytes(@NotNull byte[] input, int off, int len) { checkArrayOffs(input.length, off, len); return unsafeHash(input, BYTE_BASE + off, len); }
/** * Returns the hash code for bytes of the specified subsequence of the given {@code String}'s * underlying {@code char} array. * * <p>Default implementation could either delegate to {@link #hash(Object, Access, long, long)} * using {@link Access#toNativeCharSequence()}, or to {@link #hashChars(char[], int, int)}. * * @param input the string which bytes to hash * @param off index of the first {@code char} in the subsequence to hash * @param len length of the subsequence to hash, in chars (i. e. the length of the bytes * sequence to hash is {@code len * 2L}) * @return the hash code of the given {@code String}'s bytes * @throws IndexOutOfBoundsException if {@code off < 0} or {@code off + len > input.length()} * or {@code len < 0} */ public long hashChars(@NotNull String input, int off, int len) { checkArrayOffs(input.length(), off, len); return stringHash.longHash(input, this, off, len); }
/** * Returns the hash code for bytes of the specified subsequence of the given * {@code StringBuilder}'s underlying {@code char} array. * * <p>Default implementation could either delegate to {@link #hash(Object, Access, long, long)} * using {@link Access#toNativeCharSequence()}, or to {@link #hashChars(char[], int, int)}. * * @param input the string builder which bytes to hash * @param off index of the first {@code char} in the subsequence to hash * @param len length of the subsequence to hash, in chars (i. e. the length of the bytes * sequence to hash is {@code len * 2L}) * @return the hash code of the given {@code String}'s bytes * @throws IndexOutOfBoundsException if {@code off < 0} or {@code off + len > input.length()} * or {@code len < 0} */ public long hashChars(@NotNull StringBuilder input, int off, int len) { checkArrayOffs(input.length(), off, len); return hashNativeChars(input, off, len); }
/** * Returns the hash code for bytes, as they lay in memory, of the specified subsequence * of the given {@code char} array. * * <p>Default implementation delegates to {@link #hash(Object, Access, long, long)} method * using {@linkplain Access#unsafe() unsafe} {@code Access}. * * @param input the array to read data from * @param off index of the first {@code char} in the subsequence to hash * @param len length of the subsequence to hash, in chars (i. e. the length of the bytes * sequence to hash is {@code len * 2L}) * @return hash code for the specified subsequence * @throws IndexOutOfBoundsException if {@code off < 0} or {@code off + len > input.length} * or {@code len < 0} */ public long hashChars(@NotNull char[] input, int off, int len) { checkArrayOffs(input.length, off, len); return unsafeHash(input, CHAR_BASE + (off * 2L), len * 2L); }
/** * Returns the hash code for bytes, as they lay in memory, of the specified subsequence * of the given {@code int} array. * * <p>Default implementation delegates to {@link #hash(Object, Access, long, long)} method * using {@linkplain Access#unsafe() unsafe} {@code Access}. * * @param input the array to read data from * @param off index of the first {@code int} in the subsequence to hash * @param len length of the subsequence to hash, in ints (i. e. the length of the bytes * sequence to hash is {@code len * 4L}) * @return hash code for the specified subsequence * @throws IndexOutOfBoundsException if {@code off < 0} or {@code off + len > input.length} * or {@code len < 0} */ public long hashInts(@NotNull int[] input, int off, int len) { checkArrayOffs(input.length, off, len); return unsafeHash(input, INT_BASE + (off * 4L), len * 4L); }
/** * Returns the hash code for bytes, as they lay in memory, of the specified subsequence * of the given {@code short} array. * * <p>Default implementation delegates to {@link #hash(Object, Access, long, long)} method * using {@linkplain Access#unsafe() unsafe} {@code Access}. * * @param input the array to read data from * @param off index of the first {@code short} in the subsequence to hash * @param len length of the subsequence to hash, in shorts (i. e. the length of the bytes * sequence to hash is {@code len * 2L}) * @return hash code for the specified subsequence * @throws IndexOutOfBoundsException if {@code off < 0} or {@code off + len > input.length} * or {@code len < 0} */ public long hashShorts(@NotNull short[] input, int off, int len) { checkArrayOffs(input.length, off, len); return unsafeHash(input, SHORT_BASE + (off * 2L), len * 2L); }
/** * Returns the hash code for the specified subsequence of the given {@code ByteBuffer}. * * <p>This method doesn't alter the state (mark, position, limit or order) of the given * {@code ByteBuffer}. * * <p>Default implementation delegates to {@link #hash(Object, Access, long, long)} method * using {@link Access#toByteBuffer()}. * * @param input the buffer to read bytes from * @param off index of the first {@code byte} in the subsequence to hash * @param len length of the subsequence to hash * @return hash code for the specified subsequence * @throws IndexOutOfBoundsException if {@code off < 0} or {@code off + len > input.capacity()} * or {@code len < 0} */ public long hashBytes(@NotNull ByteBuffer input, int off, int len) { checkArrayOffs(input.capacity(), off, len); return hashByteBuffer(input, off, len); }
/** * Returns the hash code for bytes, as they lay in memory, of the specified subsequence * of the given {@code long} array. * * <p>Default implementation delegates to {@link #hash(Object, Access, long, long)} method * using {@linkplain Access#unsafe() unsafe} {@code Access}. * * @param input the array to read data from * @param off index of the first {@code long} in the subsequence to hash * @param len length of the subsequence to hash, in longs (i. e. the length of the bytes * sequence to hash is {@code len * 8L}) * @return hash code for the specified subsequence * @throws IndexOutOfBoundsException if {@code off < 0} or {@code off + len > input.length} * or {@code len < 0} */ public long hashLongs(@NotNull long[] input, int off, int len) { checkArrayOffs(input.length, off, len); return unsafeHash(input, LONG_BASE + (off * 8L), len * 8L); } }