antlr-ng
Version:
Next generation ANTLR Tool
55 lines (54 loc) • 1.82 kB
TypeScript
/**
* A stripped down MurmurHash 3 implementation for hashing values. This is used to compute hash codes for objects
* that are used in sets and maps with object identity semantics.
*/
export declare class MurmurHash {
private static readonly defaultSeed;
private constructor();
/**
* Initialize the hash using the specified {@code seed}.
*
* @param seed the seed
*
* @returns the intermediate hash value
*/
static initialize(seed?: number): number;
/**
* Update the intermediate hash value for the next input {@code value}.
*
* @param hash The intermediate hash value.
* @param value the value to add to the current hash.
*
* @returns the updated intermediate hash value
*/
static update(hash: number, value: string): number;
/**
* Apply the final computation steps to the intermediate value `hash` to form the final result of the
* MurmurHash 3 hash function.
*
* @param hash The intermediate hash value.
* @param entryCount The number of (32 bit) values added to the hash.
*
* @returns the final hash result
*/
static finish: (hash: number, entryCount: number) => number;
/**
* An all-in-one convenience method to compute a hash for a single value.
*
* @param value The value to hash.
* @param seed The seed for the hash value.
*
* @returns The computed hash.
*/
static hashCode: (value: string, seed?: number) => number;
/**
* Function to hash a string. Based on the implementation found here:
* https://stackoverflow.com/a/52171480/1137174
*
* @param hash The intermediate hash value.
* @param str The string to hash.
*
* @returns The computed hash.
*/
private static hashString;
}