hash table(全域散列法实现的哈希表)

hash table(全域散列法实现的哈希表)

利用每次重建哈希表时随机生成散列函数


#ifndef C11LEARN_HASHUNIVERSAL_H
#define C11LEARN_HASHUNIVERSAL_H
#include "Chain.h"
#include "../tools/random.h"
template<typename T>
class HashUniversal
{
   
protected:
    Chain<T>** array;
    int capacity;
    long long large_prime_numbers;
    long long a;
    long long b;
public:
    HashUniversal(int capacity = 1<<10,long long large_prime_numbers = 100001651);
    HashUniversal(const HashUniversal<T>& hashUniversal);
    const HashUniversal<T>& operator=(const HashUniversal<T>& hashUniversal);
    ~HashUniversal();
    T & operator[](int key);
    bool remove(int key);

protected:
    virtual int hashing(int key);
    void insert(Chain<T>* node);
    Chain<T>*search(int key);
    void clear();
    void copy(const HashUniversal<T> & hashUniversal);
    bool remove(Chain<T>* node);
};
template<typename T>
HashUniversal<T>::HashUniversal(int capacity,long long large_prime_numbers):capacity(capacity),large_prime_numbers(large_prime_numbers){
   
    array = new Chain
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值