可以使用哈希表来存储色盲基因库数据,通过哈希函数把 4 位色盲基因映射到哈希表中,大大提高检索的效率
#include<Windows.h>
#include<iostream>
#include<stdio.h>
using namespace std;
#define isEqual(a, b) (0==strcmp((const char*)a,(const char*)b))
#define DEFAULT_SIZE 128
typedef struct _listNode {
struct _listNode* next;
void* key;
void* data;
}listNode;
typedef listNode* list;
typedef listNode* element;
typedef struct _hashTable {
int tableSize;
list* theLists;
}hashTable;
hashTable* initHash(int tableSize);
int hashFunction(void* key, int tableSize);//哈希函数
element findElement(hashTable* &hashTable, void* key);
bool insertElement(hashTable* &hashTable, void* key, void* value);
bool deleteElement(hashTable* &hastTable, void* key);
unsigned int SDBMHash(void* key);
void destroyHash(hashTable* &hashTable);
int main() {
const char* str[] = {
"ABCD","BDCD","ACDB","BACD" };
char tester[] = "ABDCDC";
char tmp[5] = {
0};
strncpy_s(tmp,sizeof(tmp), tester + 1, 4);
hashTable* hashTab