这篇教程C++ strhash函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strhash函数的典型用法代码示例。如果您正苦于以下问题:C++ strhash函数的具体用法?C++ strhash怎么用?C++ strhash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strhash函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mymemberof/* * Determine if the user is a member of 'identifier' * Returns one of: * 0 User does not match identifier * 1 identifier matches everybody * 2 User is in the group that is identifier * 3 User is identifer */static int mymemberof(const struct auth_state *auth_state, const char *identifier){ int i; unsigned idhash = strhash(identifier); static unsigned anyonehash = 0; anyonehash = !anyonehash ? strhash("anyone") : anyonehash; if (!auth_state) { /* special case anonymous */ if (!strcmp(identifier, "anyone")) return 1; else if (!strcmp(identifier, "anonymous")) return 3; /* "anonymous" is not a member of any group */ else return 0; } /* is 'identifier' "anyone"? */ if (idhash == anyonehash && !strcmp(identifier, "anyone")) return 1; /* is 'identifier' me? */ if (idhash == auth_state->userid.hash && !strcmp(identifier, auth_state->userid.id)) return 3; /* is it a group i'm a member of ? */ for (i=0; i < auth_state->ngroups; i++) if (idhash == auth_state->groups[i].hash && !strcmp(identifier, auth_state->groups[i].id)) return 2; return 0;}
开发者ID:brong,项目名称:cyrus-imapd,代码行数:42,
示例2: dblhashRemoveint dblhashRemove(dblhash_ *h, char *key){ unsigned int code; record_ *recs; unsigned int off, ind, size; ReturnErrIf(h == NULL); ReturnErrIf(key == NULL); code = strhash(key); recs = h->records; size = sizes[h->size_index]; ind = code % size; off = 0; while (recs[ind].hash) { if ((code == recs[ind].hash) && (recs[ind].key != NULL)) { if(!strcmp(key, recs[ind].key)) { /* Do not erase hash, so probes for collisions succeed */ if((recs[ind].freeMem != 'n') && (recs[ind].key != NULL)) { free(recs[ind].key); } recs[ind].key = NULL; recs[ind].value = HUGE_VAL; h->records_count--; return 0; } } ind = (code + (int)pow(++off, 2)) % size; } ReturnErr("Couldn't find %s", key);}
开发者ID:Narrat,项目名称:python3-eispice,代码行数:34,
示例3: dblhashFindPtrint dblhashFindPtr(dblhash_ *h, char *key, double **value){ record_ *recs; unsigned int off, ind, size; unsigned int code; ReturnErrIf(h == NULL); ReturnErrIf(key == NULL); ReturnErrIf(value == NULL); code = strhash(key); recs = h->records; size = sizes[h->size_index]; ind = code % size; off = 0; /* search on hash which remains even if a record has been removed, * so hash_remove() does not need to move any collision records */ while (recs[ind].hash) { if ((code == recs[ind].hash) && (recs[ind].key != NULL)) { if(!strcmp(key, recs[ind].key)) { *value = &recs[ind].value; return 0; } } ind = (code + (int)pow(++off,2)) % size; } /* Couldn't find the key */ *value = NULL; return 0;}
开发者ID:Narrat,项目名称:python3-eispice,代码行数:34,
|