69,373
社区成员
发帖
与我相关
我的任务
分享
struct node{
void * node[256]
};
node head;
char * key = "sdada";
char * p = key;
node * pnode = &head;
void * data = 0;
do{
unsigned char c = p[0];
data = pnode->node[c];
p++;
if (!p[0]){ break;}
pnode = (node*)data;
}while(false);
struct node{
void * node[16]
};
node head;
char * key = "sdada";
char * p = key;
node * pnode = &head;
void * data = 0;
do{
unsigned char c = p[0];
int index1 = c/16;
int index2 = c%16;
pnode = (node*)pnode->node[index1];
data = (node*)pnode->node[index2];
p++;
if (!p[0]){ break;}
pnode = (node*)data;
}while(false);
time_t t = time(0);
hdc_hash_map map;
for (int i = 0; i <1000000; i++)
{
int sas = i;
map.set((const char*)(&sas),sizeof(int),0);
}
printf("%ld\n",time(0)-t);
static int hdc_pe4[256][4] = {
{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,0,3},
{0,0,1,0},{0,0,1,1},{0,0,1,2},{0,0,1,3},
{0,0,2,0},{0,0,2,1},{0,0,2,2},{0,0,2,3},
{0,0,3,0},{0,0,3,1},{0,0,3,2},{0,0,3,3},
{0,1,0,0},{0,1,0,1},{0,1,0,2},{0,1,0,3},
{0,1,1,0},{0,1,1,1},{0,1,1,2},{0,1,1,3},
{0,1,2,0},{0,1,2,1},{0,1,2,2},{0,1,2,3},
{0,1,3,0},{0,1,3,1},{0,1,3,2},{0,1,3,3},
{0,2,0,0},{0,2,0,1},{0,2,0,2},{0,2,0,3},
{0,2,1,0},{0,2,1,1},{0,2,1,2},{0,2,1,3},
{0,2,2,0},{0,2,2,1},{0,2,2,2},{0,2,2,3},
{0,2,3,0},{0,2,3,1},{0,2,3,2},{0,2,3,3},
{0,3,0,0},{0,3,0,1},{0,3,0,2},{0,3,0,3},
{0,3,1,0},{0,3,1,1},{0,3,1,2},{0,3,1,3},
{0,3,2,0},{0,3,2,1},{0,3,2,2},{0,3,2,3},
{0,3,3,0},{0,3,3,1},{0,3,3,2},{0,3,3,3},
{1,0,0,0},{1,0,0,1},{1,0,0,2},{1,0,0,3},
{1,0,1,0},{1,0,1,1},{1,0,1,2},{1,0,1,3},
{1,0,2,0},{1,0,2,1},{1,0,2,2},{1,0,2,3},
{1,0,3,0},{1,0,3,1},{1,0,3,2},{1,0,3,3},
{1,1,0,0},{1,1,0,1},{1,1,0,2},{1,1,0,3},
{1,1,1,0},{1,1,1,1},{1,1,1,2},{1,1,1,3},
{1,1,2,0},{1,1,2,1},{1,1,2,2},{1,1,2,3},
{1,1,3,0},{1,1,3,1},{1,1,3,2},{1,1,3,3},
{1,2,0,0},{1,2,0,1},{1,2,0,2},{1,2,0,3},
{1,2,1,0},{1,2,1,1},{1,2,1,2},{1,2,1,3},
{1,2,2,0},{1,2,2,1},{1,2,2,2},{1,2,2,3},
{1,2,3,0},{1,2,3,1},{1,2,3,2},{1,2,3,3},
{1,3,0,0},{1,3,0,1},{1,3,0,2},{1,3,0,3},
{1,3,1,0},{1,3,1,1},{1,3,1,2},{1,3,1,3},
{1,3,2,0},{1,3,2,1},{1,3,2,2},{1,3,2,3},
{1,3,3,0},{1,3,3,1},{1,3,3,2},{1,3,3,3},
{2,0,0,0},{2,0,0,1},{2,0,0,2},{2,0,0,3},
{2,0,1,0},{2,0,1,1},{2,0,1,2},{2,0,1,3},
{2,0,2,0},{2,0,2,1},{2,0,2,2},{2,0,2,3},
{2,0,3,0},{2,0,3,1},{2,0,3,2},{2,0,3,3},
{2,1,0,0},{2,1,0,1},{2,1,0,2},{2,1,0,3},
{2,1,1,0},{2,1,1,1},{2,1,1,2},{2,1,1,3},
{2,1,2,0},{2,1,2,1},{2,1,2,2},{2,1,2,3},
{2,1,3,0},{2,1,3,1},{2,1,3,2},{2,1,3,3},
{2,2,0,0},{2,2,0,1},{2,2,0,2},{2,2,0,3},
{2,2,1,0},{2,2,1,1},{2,2,1,2},{2,2,1,3},
{2,2,2,0},{2,2,2,1},{2,2,2,2},{2,2,2,3},
{2,2,3,0},{2,2,3,1},{2,2,3,2},{2,2,3,3},
{2,3,0,0},{2,3,0,1},{2,3,0,2},{2,3,0,3},
{2,3,1,0},{2,3,1,1},{2,3,1,2},{2,3,1,3},
{2,3,2,0},{2,3,2,1},{2,3,2,2},{2,3,2,3},
{2,3,3,0},{2,3,3,1},{2,3,3,2},{2,3,3,3},
{3,0,0,0},{3,0,0,1},{3,0,0,2},{3,0,0,3},
{3,0,1,0},{3,0,1,1},{3,0,1,2},{3,0,1,3},
{3,0,2,0},{3,0,2,1},{3,0,2,2},{3,0,2,3},
{3,0,3,0},{3,0,3,1},{3,0,3,2},{3,0,3,3},
{3,1,0,0},{3,1,0,1},{3,1,0,2},{3,1,0,3},
{3,1,1,0},{3,1,1,1},{3,1,1,2},{3,1,1,3},
{3,1,2,0},{3,1,2,1},{3,1,2,2},{3,1,2,3},
{3,1,3,0},{3,1,3,1},{3,1,3,2},{3,1,3,3},
{3,2,0,0},{3,2,0,1},{3,2,0,2},{3,2,0,3},
{3,2,1,0},{3,2,1,1},{3,2,1,2},{3,2,1,3},
{3,2,2,0},{3,2,2,1},{3,2,2,2},{3,2,2,3},
{3,2,3,0},{3,2,3,1},{3,2,3,2},{3,2,3,3},
{3,3,0,0},{3,3,0,1},{3,3,0,2},{3,3,0,3},
{3,3,1,0},{3,3,1,1},{3,3,1,2},{3,3,1,3},
{3,3,2,0},{3,3,2,1},{3,3,2,2},{3,3,2,3},
{3,3,3,0},{3,3,3,1},{3,3,3,2},{3,3,3,3}
};
这是每个字节固定的查找或者建树的规则。