📄 utils.h
字号:
#ifndef __UTILS_H__
#define __UTILS_H__
typedef struct _HASH_NODE
{
int nID;
void *p;
_HASH_NODE *pNextNode;
} HASH_NODE;
class HashTable
{
public:
HashTable(int nInitialCapacity, float fLoadFactor);
~HashTable();
void *Get(int id);
void Put(int id, void *p);
void *Delete(int id);
HASH_NODE *Enum();
int GetSize();
private:
/*
* Supplemental hash function
* This is needed to make the key more discrete, thus may improve the lookup performance.
*
* This function is same as the hash function of java.util.HashMap of Sun's Java2 SDK 1.4.
*/
int Hash(int key)
{
key += ~(key << 9);
key ^= (key >> 14);
key += (key << 4);
key ^= (key >> 10);
return key;
}
void Rebuild();
float fLoadFactor;
int nInitialCapacity, nCapacity, nSize;
HASH_NODE **ppBuffer;
};
typedef struct _LINKED_LIST_NODE
{
void *p;
_LINKED_LIST_NODE *pPrevNode;
_LINKED_LIST_NODE *pNextNode;
} LINKED_LIST_NODE;
class FIFO
{
public:
FIFO();
~FIFO();
void Put(void *pConn);
void *Get();
void *Peek();
private:
int nSize;
LINKED_LIST_NODE *pIdlePool;
};
#endif // #ifndef __UTILS_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -