本文整理汇总了C++中HASH_COUNT函数的典型用法代码示例。如果您正苦于以下问题:C++ HASH_COUNT函数的具体用法?C++ HASH_COUNT怎么用?C++ HASH_COUNT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HASH_COUNT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: bufnew
caryll_buffer *caryll_write_gsub_ligature_subtable(otl_subtable *_subtable) {
caryll_buffer *buf = bufnew();
subtable_gsub_ligature *subtable = &(_subtable->gsub_ligature);
ligature_aggerator *h = NULL, *s, *tmp;
uint16_t nLigatures = subtable->to->numGlyphs;
for (uint16_t j = 0; j < nLigatures; j++) {
int sgid = subtable->from[j]->glyphs[0].gid;
HASH_FIND_INT(h, &sgid, s);
if (!s) {
NEW(s);
s->gid = sgid;
s->ligid = HASH_COUNT(h);
HASH_ADD_INT(h, gid, s);
}
}
HASH_SORT(h, by_gid);
otl_coverage *startCoverage;
NEW(startCoverage);
startCoverage->numGlyphs = HASH_COUNT(h);
NEW_N(startCoverage->glyphs, startCoverage->numGlyphs);
uint16_t jj = 0;
foreach_hash(s, h) {
s->ligid = jj;
startCoverage->glyphs[jj].gid = s->gid;
startCoverage->glyphs[jj].name = NULL;
jj++;
}
开发者ID:jojoblack,项目名称:otfcc,代码行数:29,代码来源:gsub-ligature.c
示例2: moloch_session_monitoring
uint32_t moloch_session_monitoring()
{
uint32_t count = 0;
int i;
for (i = 0; i < config.packetThreads; i++) {
count += HASH_COUNT(h_, sessions[i][SESSION_TCP]) + HASH_COUNT(h_, sessions[i][SESSION_UDP]) + HASH_COUNT(h_, sessions[i][SESSION_ICMP]);
}
return count;
}
开发者ID:pstray,项目名称:moloch,代码行数:10,代码来源:session.c
示例3: consolidate_gsub_single
bool consolidate_gsub_single(caryll_font *font, table_otl *table, otl_subtable *_subtable,
sds lookupName) {
subtable_gsub_single *subtable = &(_subtable->gsub_single);
consolidate_coverage(font, subtable->from, lookupName);
consolidate_coverage(font, subtable->to, lookupName);
uint16_t len =
(subtable->from->numGlyphs < subtable->to->numGlyphs ? subtable->from->numGlyphs
: subtable->from->numGlyphs);
gsub_single_map_hash *h = NULL;
for (uint16_t k = 0; k < len; k++) {
if (subtable->from->glyphs[k].name && subtable->to->glyphs[k].name) {
gsub_single_map_hash *s;
int fromid = subtable->from->glyphs[k].gid;
HASH_FIND_INT(h, &fromid, s);
if (s) {
fprintf(stderr, "[Consolidate] Double-mapping a glyph in a "
"single substitution /%s.\n",
subtable->from->glyphs[k].name);
} else {
NEW(s);
s->fromid = subtable->from->glyphs[k].gid;
s->toid = subtable->to->glyphs[k].gid;
s->fromname = subtable->from->glyphs[k].name;
s->toname = subtable->to->glyphs[k].name;
HASH_ADD_INT(h, fromid, s);
}
}
}
HASH_SORT(h, by_from_id);
if (HASH_COUNT(h) != subtable->from->numGlyphs || HASH_COUNT(h) != subtable->to->numGlyphs) {
fprintf(stderr, "[Consolidate] In single subsitution lookup %s, some "
"mappings are ignored.\n",
lookupName);
}
subtable->from->numGlyphs = HASH_COUNT(h);
subtable->to->numGlyphs = HASH_COUNT(h);
FREE(subtable->from->glyphs);
FREE(subtable->to->glyphs);
NEW_N(subtable->from->glyphs, subtable->from->numGlyphs);
NEW_N(subtable->to->glyphs, subtable->to->numGlyphs);
{
gsub_single_map_hash *s, *tmp;
uint16_t j = 0;
HASH_ITER(hh, h, s, tmp) {
subtable->from->glyphs[j].gid = s->fromid;
subtable->from->glyphs[j].name = s->fromname;
subtable->to->glyphs[j].gid = s->toid;
subtable->to->glyphs[j].name = s->toname;
j++;
HASH_DEL(h, s);
free(s);
}
}
开发者ID:gitter-badger,项目名称:otfcc,代码行数:53,代码来源:gsub-single.c
示例4: matchInodefiles
int matchInodefiles(void) {
fileop_t *f;
fileop_t *finode;
char fpath[PATH_MAX];
struct stat st;
int64_t inode;
// first try to match inodefiles to files
for (f = files; f != NULL; f = (fileop_t*) (f->hh.next)) {
// get ino of the file
getAbsolutePath(fpath, config.snapshot, f->relpath);
if (stat(fpath, &st) != -1) {
inode = st.st_ino;
} else {
// this should not happen: we can't open the file
errMsg(LOG_WARNING, "Could not stat file %s ", fpath);
}
// if this ino is in inodefiles, merge the operations in f and
// remove the element from inodefiles
// TODO: what about order?
HASH_FIND_INT(inodefiles, &inode, finode);
if (finode != NULL) {
if (mergeOperations(f, finode) != 0)
return -1;
free(finode->operations);
HASH_DEL(inodefiles, finode);
free(finode);
}
// if there are no entries in inodefiles left, we are done
if (HASH_COUNT(inodefiles) == 0) // HASH_COUNT is cheap
return 0;
}
// the rest must be matched by file tree walk (nftw)
int flags = 0;
flags |= FTW_MOUNT; // stay in the file system
flags |= FTW_PHYS; // do not dereference symlinks
if (nftw(config.snapshot, matchInode, 10, flags) == -1) {
errMsg(LOG_WARNING, "Could not stat file %s ", fpath);
}
// if there are still some entries left in inodefiles, we have a problem
if (HASH_COUNT(inodefiles) == 0)
return 0;
else
return -1;
}
开发者ID:lukasfrelich,项目名称:syncedfs,代码行数:52,代码来源:client.c
示例5: MAT_PARSER_show
void MAT_PARSER_show(Parser* p) {
// Local variables
MAT_Parser* parser = (MAT_Parser*)PARSER_get_data(p);
int len_bus_list;
int len_branch_list;
int len_gen_list;
int len_cost_list;
int len_util_list;
// No parser
if (!parser)
return;
// List lengths
LIST_len(MAT_Bus,parser->bus_list,next,len_bus_list);
LIST_len(MAT_Branch,parser->branch_list,next,len_branch_list);
LIST_len(MAT_Gen,parser->gen_list,next,len_gen_list);
LIST_len(MAT_Cost,parser->cost_list,next,len_cost_list);
LIST_len(MAT_Util,parser->util_list,next,len_util_list);
// Show
printf("\nParsed Data\n");
printf("base power : %.2f\n",parser->base_power);
printf("bus list : %d\n",len_bus_list);
printf("bus hash : %d\n",HASH_COUNT(parser->bus_hash));
printf("gen list : %d\n",len_gen_list);
printf("branch list: %d\n",len_branch_list);
printf("cost list : %d\n",len_cost_list);
printf("util list : %d\n",len_util_list);
}
开发者ID:entriken,项目名称:PFNET,代码行数:31,代码来源:parser_MAT.c
示例6: olsr_db_rt_report_so
int olsr_db_rt_report_so(char** str_out) {
int report_str_len = 70;
olsr_db_rt_t* current_entry = rt_set;
char* output;
char entry_str[report_str_len + 1];
output = malloc(sizeof(char) * report_str_len * (HASH_COUNT(rt_set)) + 1);
if(output == NULL) {
return false;
}
struct timeval curr_time;
gettimeofday(&curr_time, NULL);
// initialize first byte to \0 to mark output as empty
*output = '\0';
while(current_entry != NULL) {
snprintf(entry_str, report_str_len + 1, MAC "\t" MAC "\t" MAC "\t%i\t%5.2f\n",
EXPLODE_ARRAY6(current_entry->dest_addr), EXPLODE_ARRAY6(current_entry->next_hop), EXPLODE_ARRAY6(current_entry->precursor_addr), current_entry->hop_count, current_entry->link_quality);
strcat(output, entry_str);
current_entry = current_entry->hh.next;
}
*str_out = output;
return true;
}
开发者ID:Dekue,项目名称:des-routing-algorithms,代码行数:29,代码来源:routing_table.c
示例7: unit_end
void unit_end(unit_table_t *unit)
{
struct link_unit_t *ut;
char buf[10240];
if(unit->valid == true || HASH_COUNT(unit->link_unit) > 1) {
bzero(buf, 10240);
// emit linked unit lists;
if(unit->link_unit != NULL) {
sprintf(buf, "type=unit list=\"");
for(ut=unit->link_unit; ut != NULL; ut=ut->hh.next) {
sprintf(buf+strlen(buf), "%d-%d,", ut->id.tid, ut->id.unitid);
}
sprintf(buf+strlen(buf), "\" tid=%d \n", unit->tid);
emit_log(unit, buf);
}
}
delete_unit_hash(unit->link_unit, unit->mem_unit);
//if(unit->link_unit != NULL) printf("link_unit is not NULL %p\n", unit->link_unit);
unit->link_unit = NULL;
unit->mem_unit = NULL;
unit->valid = false;
unit->r_addr = 0;
unit->w_addr = 0;
unit->unitid++;
}
开发者ID:kyuhlee,项目名称:UBSI,代码行数:27,代码来源:audisp-example.c
示例8: draw_particles
int draw_particles(void)
{
static Vec pointv[512];
static size_t pointc = ARRLEN(pointv, Vec);
double z = zoom();
particle_t* p = particles;
int i = 0;
size_t count = HASH_COUNT(particles);
while(i < count) {
for(; p != NULL && i < pointc; p = p->hh.next, i++) {
cpVect pos = cpBodyGetPos(p->body);
if(fabs(pos.x) <= z / 2 && fabs(pos.y) <= z / 2) {
// rough check if position is inside screen borders
// TODO: possibly make it separate function
pointv[i] = cpv2vec(pos);
}
}
if(draw_points(pointv, i % pointc)) {
return -1;
}
}
return 0;
}
开发者ID:niksaak,项目名称:dame,代码行数:26,代码来源:particle.c
示例9: while
static struct node *try_flat_dump(struct node *tree)
{
struct node *current;
current = tree;
while (current != NULL)
{
if (HASH_COUNT(current) == 1)
{
printf("%s ", current->word);
if (current->childs == NULL)
{
printf("\n");
return NULL;
}
}
else
{
printf("\n");
return current;
}
current = current->childs;
}
printf("\n");
return current;
}
开发者ID:JulienPalard,项目名称:Mine,代码行数:26,代码来源:dump.c
示例10: get_num_nodes
uint32_t get_num_nodes(Graph *graph){
if(graph == NULL){
puts("Error: get_node graph given is null.");
exit(1);
}
return (uint32_t)HASH_COUNT(graph->nodes);
}
开发者ID:monological,项目名称:fastroute,代码行数:7,代码来源:graph.c
示例11: print_bot_list
void print_bot_list(void)
{
struct bot *b, *tmp;
if (HASH_COUNT(bots) == 0)
printf("No bots!\n");
HASH_ITER(hh, bots, b, tmp) {
printf("%s: %s\n", b->name, b->desc);
}
开发者ID:tomtix,项目名称:planetwars,代码行数:8,代码来源:option.c
示例12: main
int
main (int argc, char *argv[])
{
char in[10];
int id = 1;
User *s;
unsigned num_users;
while (1)
{
printf ("1. add user\n");
printf ("2. find user\n");
printf ("3. delete user\n");
printf ("4. delete all users\n");
printf ("5. sort items by name\n");
printf ("6. sort items by id\n");
printf ("7. print users\n");
printf ("8. count users\n");
gets (in);
switch (atoi (in))
{
case 1:
printf ("name?\n");
add_user (id++, gets (in));
break;
case 2:
printf ("id?\n");
s = find_user (atoi (gets (in)));
printf ("user: %s\n", s ? s->name : "unknown");
break;
case 3:
printf ("id?\n");
s = find_user (atoi (gets (in)));
if (s)
delete_user (s);
else
printf ("id unknown\n");
break;
case 4:
delete_all ();
break;
case 5:
sort_by_name ();
break;
case 6:
sort_by_id ();
break;
case 7:
print_users ();
break;
case 8:
num_users = HASH_COUNT (users);
printf ("there are %u users\n", num_users);
break;
}
}
}
开发者ID:bugcy013,项目名称:pgstatmib,代码行数:57,代码来源:example2.c
示例13: overlap_coefficient_similarity_custom
const float overlap_coefficient_similarity_custom(const char *str1, const char *str2, std_tokenizer_t *tokenizer) {
hash_token_t *h1 = tokenizer->tok_uq_hash_func(str1, tokenizer->delimiters);
hash_token_t *h2 = tokenizer->tok_uq_hash_func(str2, tokenizer->delimiters);
hash_token_t *all = merge_tokens(h1, h2);
unsigned int ch1 = HASH_COUNT(h1), ch2 = HASH_COUNT(h2), ch3 = HASH_COUNT(all);
unsigned int ct = (ch1 + ch2) - ch3;
const float ret = ((float) ct) / ((float) MIN((float)ch1, (float)ch2));
hash_token_free(h1);
hash_token_free(h2);
hash_token_free(all);
return ret;
}
开发者ID:Simmetrics,项目名称:libsimmetrics,代码行数:19,代码来源:overlap_coefficient.c
示例14: cosine_similarity_custom
const float cosine_similarity_custom(const char *str1, const char *str2, std_tokenizer_t *tokenizer) {
hash_token_t *h1 = tokenizer->tok_uq_hash_func(str1, tokenizer->delimiters);
hash_token_t *h2 = tokenizer->tok_uq_hash_func(str2, tokenizer->delimiters);
hash_token_t *all = merge_tokens(h1, h2);
unsigned int ch1 = HASH_COUNT(h1), ch2 = HASH_COUNT(h2), ch3 = HASH_COUNT(all);
unsigned int ct = (ch1 + ch2) - ch3;
const float ret = ((float)ct / (powf((float)ch1, (float)0.5) * powf((float)ch2, (float)0.5)));
hash_token_free(h1);
hash_token_free(h2);
hash_token_free(all);
return ret;
}
开发者ID:Simmetrics,项目名称:libsimmetrics,代码行数:19,代码来源:cosine_similarity.c
示例15: pm_next_loop
int pm_next_loop(void (*child_changed_status)(process_struct *ps))
{
sigsetjmp(saved_jump_buf, 1); pm_can_jump = 0;
while (!terminated && (HASH_COUNT(exited_children) > 0 || signaled)) pm_check_children(child_changed_status, terminated);
pm_check_pending_processes(); // Check for pending signals arrived while we were in the signal handler
pm_can_jump = 1;
if (terminated) return -1;
else return 0;
}
开发者ID:bharad,项目名称:babysitter,代码行数:11,代码来源:process_manager.c
示例16: transfer
int transfer(char *host, char *port) {
int sfd; // server socket
fileop_t *f; // contains all operations for a file
sfd = inetConnect(host, port, SOCK_STREAM);
if (sfd == -1) {
errnoMsg(LOG_ERR, "Unable to connect to the server.");
return -1;
}
// initiate sync (sync-id, resource, number of files)
errMsg(LOG_INFO, "Number of files: %d", HASH_COUNT(files));
switch (initiateSync(sfd, HASH_COUNT(files))) {
case -1: // error
return -1;
case -2: // there's nothing to synchronize
return 0;
default:
break;
}
// iterate over files in correct order
HASH_SORT(files, sortByOrder);
for (f = files; f != NULL; f = (fileop_t*) (f->hh.next)) {
if (transferFile(sfd, f) == -1) {
errMsg(LOG_ERR, "Transfer of file %s has failed.",
f->relpath);
return -1;
}
}
// wait for ACK
SyncFinish *conf;
conf = (SyncFinish *) recvMessage(sfd, SyncFinishType, NULL);
if (conf == NULL) {
errMsg(LOG_ERR, "Could not get transfer confirmation.");
return -1;
}
return 0;
}
开发者ID:lukasfrelich,项目名称:syncedfs,代码行数:41,代码来源:client.c
示例17: olc_delete_mobile
/**
* WARNING: This function actually deletes a mobile from the world.
*
* @param char_data *ch The person doing the deleting.
* @param mob_vnum vnum The vnum to delete.
*/
void olc_delete_mobile(char_data *ch, mob_vnum vnum) {
void extract_pending_chars();
void remove_mobile_from_table(char_data *mob);
char_data *proto, *mob_iter, *next_mob;
descriptor_data *desc;
struct global_data *glb, *next_glb;
room_template *rmt, *next_rmt;
sector_data *sect, *next_sect;
crop_data *crop, *next_crop;
bld_data *bld, *next_bld;
bool found;
if (!(proto = mob_proto(vnum))) {
msg_to_char(ch, "There is no such mobile %d.\r\n", vnum);
return;
}
if (HASH_COUNT(mobile_table) <= 1) {
msg_to_char(ch, "You can't delete the last mob.\r\n");
return;
}
// remove mobs from the list: DO THIS FIRST
for (mob_iter = character_list; mob_iter; mob_iter = next_mob) {
next_mob = mob_iter->next;
if (IS_NPC(mob_iter)) {
if (GET_MOB_VNUM(mob_iter) == vnum) {
// this is the removed mob
act("$n has been deleted.", FALSE, mob_iter, NULL, NULL, TO_ROOM);
extract_char(mob_iter);
}
}
}
// their data will already be free, so we need to clear them out now
extract_pending_chars();
// pull from hash ONLY after removing from the world
remove_mobile_from_table(proto);
// save mob index and mob file now so there's no trouble later
save_index(DB_BOOT_MOB);
save_library_file_for_vnum(DB_BOOT_MOB, vnum);
// update buildings
HASH_ITER(hh, building_table, bld, next_bld) {
found = delete_mob_from_spawn_list(&GET_BLD_SPAWNS(bld), vnum);
found |= delete_from_interaction_list(&GET_BLD_INTERACTIONS(bld), TYPE_MOB, vnum);
if (found) {
save_library_file_for_vnum(DB_BOOT_BLD, GET_BLD_VNUM(bld));
}
}
开发者ID:Marchearth,项目名称:EmpireMUD-2.0-Beta,代码行数:59,代码来源:olc.mobile.c
示例18: send_tc
dessert_per_result_t send_tc(void *data, struct timeval *scheduled, struct timeval *interval) {
pthread_rwlock_wrlock(&pp_rwlock);
if (HASH_COUNT(dir_neighbors_head) == 0) {
return 0;
}
dessert_msg_t *tc;
dessert_msg_new(&tc);
tc->ttl = TTL_MAX;
tc->u8 = ++tc_seq_nr;
// delete old entries from NH list
node_neighbors_t *dir_neigh = dir_neighbors_head;
while (dir_neigh) {
if (dir_neigh->entry_age-- == 0) {
node_neighbors_t* el_to_delete = dir_neigh;
HASH_DEL(dir_neighbors_head, el_to_delete);
free(el_to_delete);
}
dir_neigh = dir_neigh->hh.next;
}
// add TC extension
dessert_ext_t *ext;
uint8_t ext_size = 1 + ((sizeof(node_neighbors_t)- sizeof(dir_neighbors_head->hh)) * HASH_COUNT(dir_neighbors_head));
dessert_msg_addext(tc, &ext, LSR_EXT_TC, ext_size);
void* tc_ext = ext->data;
memcpy(tc_ext, &(ext_size), 1);
tc_ext++;
// copy NH list into extension
dir_neigh = dir_neighbors_head;
while (dir_neigh) {
memcpy(tc_ext, dir_neigh->addr, ETH_ALEN);
tc_ext += ETH_ALEN;
memcpy(tc_ext, &(dir_neigh->entry_age), 1);
tc_ext++;
memcpy(tc_ext, &(dir_neigh->weight), 1);
tc_ext++;
dir_neigh = dir_neigh->hh.next;
}
// add l2.5 header
dessert_msg_addext(tc, &ext, DESSERT_EXT_ETH, ETHER_HDR_LEN);
struct ether_header* l25h = (struct ether_header*) ext->data;
memcpy(l25h->ether_shost, dessert_l25_defsrc, ETH_ALEN);
memcpy(l25h->ether_dhost, ether_broadcast, ETH_ALEN);
dessert_meshsend_fast(tc, NULL);
dessert_msg_destroy(tc);
pthread_rwlock_unlock(&pp_rwlock);
return 0;
}
开发者ID:Dekue,项目名称:des-routing-algorithms,代码行数:53,代码来源:des-lsr_routinglogic.c
示例19: moloch_session_add_tag_type
void moloch_session_add_tag_type(MolochSession_t *session, int tagtype, const char *tag) {
moloch_session_incr_outstanding(session);
moloch_db_get_tag(session, tagtype, tag, moloch_session_get_tag_cb);
if (session->stopSaving == 0 && HASH_COUNT(s_, config.dontSaveTags)) {
MolochString_t *tstring;
HASH_FIND(s_, config.dontSaveTags, tag, tstring);
if (tstring) {
session->stopSaving = (long)tstring->uw;
}
}
}
开发者ID:pstray,项目名称:moloch,代码行数:13,代码来源:session.c
示例20: remove_tex
void remove_tex(unsigned int idmin, unsigned int idmax)
{
unsigned int n = 0;
texlist *current, *tmp;
GLuint *t = (GLuint*)malloc(HASH_COUNT(list) * sizeof(GLuint));
HASH_ITER(hh, list, current, tmp)
{
if (current->id >= idmin && current->id < idmax)
{
t[n++] = current->tex_id;
HASH_DEL(list, current);
free(current);
}
}
glDeleteTextures(n, t);
free(t);
#ifdef LOG_TEXTUREMEM
if (log_cb)
log_cb(RETRO_LOG_DEBUG, "RMVTEX nbtex is now %d (%06x - %06x)\n", HASH_COUNT(list), idmin, idmax);
#endif
}
开发者ID:matthewbauer,项目名称:mupen64plus-libretro,代码行数:22,代码来源:glitchtextureman_hash.cpp
注:本文中的HASH_COUNT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论