Skip to main content

HashFunction

Type Alias HashFunction 

Source
pub type HashFunction = fn(&[u8], usize, usize) -> Vec<u32>;
Expand description

A type alias for the hash function used in the Bloom filter.

This function takes an input item and computes multiple hash indices for the Bloom filter’s bit vector.

Parameters:

  • item: &[u8]
    • A byte slice representing the item to be hashed.
  • num_hashes: usize
    • The number of hash values to compute for the item.
  • capacity: usize
    • The size of the Bloom filter’s bit vector. This ensures that the generated hash indices are within valid bounds.

Returns:

  • Vec<u32>
    • A vector of hash indices corresponding to positions in the bit vector.

Usage:

The hash function computes num_hashes hash indices for the given item, ensuring each index is within the range [0, capacity). These indices are used to set or check bits in the Bloom filter’s bit vector.