public class FastStringHasher extends AbstractStringHasher
StringHasher
.Modifier and Type | Field and Description |
---|---|
private static int |
HASH_FACTOR
The hash-factor - should be prime (however Bernstein uses 33).
|
Constructor and Description |
---|
FastStringHasher()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getHashCode(char[] string,
int start,
int end)
This method gets the hash-code for the specified
subsequence of the
given string . |
int |
getHashCode(CharSequence string,
int start,
int end)
This method gets the hash-code for the specified
subsequence of the
given string . |
int[] |
getHashCodes(char[] string,
int length,
int stringStart,
int stringEnd)
This method gets the hash-codes for all
subsequence of string
from stringStart (inclusive) until stringEnd (exclusive) that have the given length . |
getHashCode, getHashCodes, getHashCodes, getHashCodes
private static final int HASH_FACTOR
public int getHashCode(char[] string, int start, int end)
StringHasher
string
- is the char-array containing the substring
to hash.start
- is the index of the first character to include into the hash.end
- is the index one before the last character to include into the hash.Object.hashCode()
public int getHashCode(CharSequence string, int start, int end)
StringHasher
getHashCode
in interface StringHasher
getHashCode
in class AbstractStringHasher
string
- is the CharSequence
containing the subsequence
to
hash.start
- is the index of the first character to include into the hash.end
- is the index one before the last character to include into the hash.Object.hashCode()
public int[] getHashCodes(char[] string, int length, int stringStart, int stringEnd)
StringHasher
subsequence
of string
from stringStart
(inclusive) until stringEnd
(exclusive) that have the given length
.
int size = stringEnd - stringStart - length + 1;
if (size <= 0) {
return new int[0];
}
int[] result = new int[size];
for (int i = 0; i < size; i++) {
result[i] = getHashCode
(string, i, i + length);
}
return result;
getHashCodes
in interface StringHasher
getHashCodes
in class AbstractStringHasher
string
- is the string as char-array.length
- is the length
of the sub-sequences
of string
to hash.stringStart
- is the index where to start in string
.stringEnd
- is the index where to stop in string
.string
is less than the given
length
.Copyright © 2001–2016 mmm-Team. All rights reserved.