当前位置: 首页>>代码示例>>C++>>正文


C++ HASH_COUNT函数代码示例

本文整理汇总了C++中HASH_COUNT函数的典型用法代码示例。如果您正苦于以下问题:C++ HASH_COUNT函数的具体用法?C++ HASH_COUNT怎么用?C++ HASH_COUNT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HASH_COUNT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的HASH_COUNT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。