| java.lang.Object org.apache.xerces.utils.StringHasher
StringHasher | final public class StringHasher (Code) | | Algorithm used to hash char arrays (strings).
This class was created after it was discovered that parsing some
documents was unexpectedly slow due to many different strings
hashing to the same 32-bit value using the java.lang.String hash
algorithm.
The trick seems to be the shift of the top eight bits of the hashcode
back down to the bottom to keep them from being rolled out.
|
Method Summary | |
public static int | finishHash(int hashcode) | public static int | hashChar(int hashcode, int ch) generate partially completed character hashcode. | public static int | hashChars(char[] chars, int offset, int length) | public static int | hashString(String str, int strLength) |
finishHash | public static int finishHash(int hashcode)(Code) | | finish hashing a partically completed character hashcode
See Also: StringHasher.hashChar(int,int) Parameters: hashcode - a partially completed character hashcode a character hashcode |
hashChar | public static int hashChar(int hashcode, int ch)(Code) | | generate partially completed character hashcode.
this is mean to be iterated over individual characters in order to generate
a full hash value
See Also: StringHasher.finishHash(int) Parameters: hashcode - a partially completed character hashcode Parameters: ch - the character to hash a partially completed character hashcode |
hashChars | public static int hashChars(char[] chars, int offset, int length)(Code) | | generate a hashcode for a character array
Parameters: chars - the array to hash Parameters: offset - the offset to start hashing Parameters: length - the length of characters to hash hashcode for the character array |
hashString | public static int hashString(String str, int strLength)(Code) | | generate a hashcode for a String
Parameters: str - the String to hash Parameters: strLength - the length of the String to hash hashcode for the String |
|
|