📄 hash.h
字号:
// Hash.h: interface for the CHash class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_HASH_H__E823F48D_15F3_44D0_A75F_352B6DEB0020__INCLUDED_)
#define AFX_HASH_H__E823F48D_15F3_44D0_A75F_352B6DEB0020__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/* Table is sized by primes to minimise clustering.
See: http://planetmath.org/encyclopedia/GoodHashTablePrimes.html */
static const unsigned int sizes[] = {
53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 98317,
196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917, 25165843,
50331653, 100663319, 201326611, 402653189, 805306457, 1610612741
};
static const int sizes_count = sizeof(sizes) / sizeof(sizes[0]);
/*hash表上限因子,当大于这个因子时,需要增长hash表*/
static const float load_factor = 0.65;
struct record {
unsigned int hash;
const char *key;
void *value;
};
struct hash {
struct record *records;
unsigned int records_count;
unsigned int size_index;
};
class CHash
{
public:
CHash();
virtual ~CHash();
// int hash_grow(hash *h);
// unsigned int strhash(const char *str);
// hash* hash_new(unsigned int capacity);
// void hash_destroy(hash *h);
// int hash_add(hash *h, const char *key, void *value);
// void* hash_get(hash *h, const char *key);
// void* hash_remove(hash *h, const char *key);
// unsigned int hash_size(hash *h);
};
#endif // !defined(AFX_HASH_H__E823F48D_15F3_44D0_A75F_352B6DEB0020__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -