1 package net.jpountz.xxhash;
3 import java.nio.ByteBuffer;
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 * Instances of this class are thread-safe.
24 public abstract class XXHash32 {
27 * Compute the 32-bits hash of <code>buf[off:off+len]</code> using seed
30 public abstract int hash(byte[] buf, int off, int len, int seed);
33 * Compute the hash of the given slice of the {@link ByteBuffer}.
34 * {@link ByteBuffer#position() position} and {@link ByteBuffer#limit() limit}
37 public abstract int hash(ByteBuffer buf, int off, int len, int seed);
40 * Compute the hash of the given {@link ByteBuffer}. The
41 * {@link ByteBuffer#position() position} is moved in order to reflect bytes
42 * which have been read.
44 public final int hash(ByteBuffer buf, int seed) {
45 final int hash = hash(buf, buf.position(), buf.remaining(), seed);
46 buf.position(buf.limit());
51 public String toString() {
52 return getClass().getSimpleName();