Files
hash-map/src/interfaces/IHashFunction.ts

16 lines
492 B
TypeScript

/**
* Interface for hash functions.
* Follows Interface Segregation Principle (ISP) and Dependency Inversion Principle (DIP).
* Allows different hashing strategies to be implemented and injected.
*/
export interface IHashFunction<K> {
/**
* Computes a hash value for the given key.
* @param key - The key to hash
* @param capacity - The current capacity of the hash table
* @returns A hash value in the range [0, capacity)
*/
hash(key: K, capacity: number): number;
}