• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ HASH_ADD_INT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了HASH_ADD_INT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: HASH_FIND_INT

page_node *add_page(stored_object *object, uint32_t page_id)
{
    page_node *curr,*page;

    HASH_FIND_INT(global_page_table,&page_id,page);
    if(page)
    {
        printf("ERROR[add_page] Object %lu already contains page %d\n",page->object_id,page_id);
        return NULL;
    }

    object->size += PAGE_SIZE;
    if(object->pages == NULL)
    {
        page = allocate_new_page(object->id,page_id);
        HASH_ADD_INT(global_page_table, page_id, page); 
        object->pages = page;
        return object->pages;
    }
    for(curr=page=object->pages; page && page->page_id != page_id; curr=page,page=page->next)
        ;
    if(page)
    {
        printf("ERROR[add_page] Object %lu already contains page %d\n",page->object_id,page_id);
        return NULL;
    }

    page = allocate_new_page(object->id,page_id);
    HASH_ADD_INT(global_page_table, page_id, page); 
    curr->next = page;
    return curr->next;
}
开发者ID:bkreitch,项目名称:simulator,代码行数:32,代码来源:ftl_obj_strategy.c


示例2: main

int main() {
  item *i, *j, *items=NULL;
  int k;

  /* first item */
  k = 12345;
  i = (item*)malloc(sizeof(item));
  i->key = k; i->data = 0;
  HASH_ADD_INT(items,key,i);

  /* second item */
  k = 6789;
  i = (item*)malloc(sizeof(item));
  i->key = k; i->data = 0;
  HASH_ADD_INT(items,key,i);

  /* third item */
  k = 98765;
  i = (item*)malloc(sizeof(item));
  i->key = k; i->data = 0;
  HASH_ADD_INT(items,key,i);

  /* look them all up */
  k = 12345; HASH_FIND_INT(items, &k, j); if (j) printf("found %d\n",k);
  k = 6789;  HASH_FIND_INT(items, &k, j); if (j) printf("found %d\n",k);
  k = 98765; HASH_FIND_INT(items, &k, j); if (j) printf("found %d\n",k);

  /* delete them not the way we prefer but it works */
  for(j=items; j != NULL; j=(item*)j->hh.next) {
    printf("deleting %d\n", j->key);
    HASH_DEL(items,j);
  }
  return 0;
}
开发者ID:Agyar,项目名称:uthash,代码行数:34,代码来源:test23.c


示例3: mkparticle

int mkparticle(particle_kind_t kind, cpVect pos, cpVect impulse, double energy)
{
  particle_t* p = malloc(sizeof *p);
  if(p == NULL) {
    return -1; // bad malloc
  }
  cpSpace* space = current_space();
  cpBody* body = cpBodyNew(energy / 1000.0, particle_moi);
  cpShape* shape = cpCircleShapeNew(body, particle_r, cpvzero);

  cpBodySetUserData(body, p);
  cpShapeSetUserData(shape, p);
  cpSpaceAddBody(space, body);
  cpSpaceAddShape(space, shape);
  *p = (particle_t){
    .id = id,
    .kind = kind,
    .energy = energy,
    .life = energy,
    .body = body
  };
  HASH_ADD_INT(particles, id, p);

  return id++;
}
开发者ID:niksaak,项目名称:dame,代码行数:25,代码来源:particle.c


示例4: CCASSERT

void ActionManager::addAction(Action *pAction, Node *target, bool paused)
{
    CCASSERT(pAction != NULL, "");
    CCASSERT(target != NULL, "");

    tHashElement *pElement = NULL;
    // we should convert it to Object*, because we save it as Object*
    Object *tmp = target;
    HASH_FIND_INT(_targets, &tmp, pElement);
    if (! pElement)
    {
        pElement = (tHashElement*)calloc(sizeof(*pElement), 1);
        pElement->paused = paused;
        target->retain();
        pElement->target = target;
        HASH_ADD_INT(_targets, target, pElement);
    }

     actionAllocWithHashElement(pElement);
 
     CCASSERT(! ccArrayContainsObject(pElement->actions, pAction), "");
     ccArrayAppendObject(pElement->actions, pAction);
 
     pAction->startWithTarget(target);
}
开发者ID:KIngpon,项目名称:HXGame,代码行数:25,代码来源:CCActionManager.cpp


示例5: farray_create

/**
 * Return an array of prototypes labeled with cluster numbers
 * @param c cluster structure
 * @param a assignment of prototypes
 * @param p prototypes
 * @return rejected feature vectors
 */
farray_t *cluster_get_prototypes(cluster_t *c, assign_t *a, farray_t *p)
{
    int i;
    farray_t *n = farray_create("prototypes");
    count_t *hash = NULL, *entry;

    for (i = 0; i < a->len; i++) {
        /* Skip rejected clusters */
        if (!c->cluster[i])
            continue;

        /* Check if prototype has been added */
        int j = a->proto[i];
        HASH_FIND_INT(hash, &j, entry);
        if (entry)
            continue;

        /* Add new prototype */
        entry = malloc(sizeof(count_t));
        entry->label = j;
        HASH_ADD_INT(hash, label, entry);

        /* Add prototype */
        farray_add(n, fvec_clone(p->x[j]), cluster_get_name(c, i));
    }

    /* Delete hash table */
    while (hash) {
        entry = hash;
        HASH_DEL(hash, entry);
        free(entry);
    }

    return n;
}
开发者ID:JaonLin,项目名称:malheur,代码行数:42,代码来源:cluster.c


示例6: AllocDispatchIndex

static GLboolean AllocDispatchIndex(__GLXvendorInfo *vendor,
                                    const GLubyte *procName)
{
    __GLXdispatchIndexHash *pEntry = malloc(sizeof(*pEntry));
    if (!pEntry) {
        return GL_FALSE;
    }

    pEntry->procName = (GLubyte *)strdup((const char *)procName);
    if (!pEntry->procName) {
        free(pEntry);
        return GL_FALSE;
    }

    LKDHASH_WRLOCK(__glXPthreadFuncs, __glXDispatchIndexHash);
    pEntry->index = __glXNextUnusedHashIndex++;

    // Notify the vendor this is the index which should be used
    vendor->staticDispatch->
        glxvc.setDispatchIndex(procName, pEntry->index);

    HASH_ADD_INT(_LH(__glXDispatchIndexHash),
                 index, pEntry);
    LKDHASH_UNLOCK(__glXPthreadFuncs, __glXDispatchIndexHash);

    return GL_TRUE;
}
开发者ID:aritger,项目名称:libglvnd,代码行数:27,代码来源:libglxmapping.c


示例7: consolidate_gpos_single

bool consolidate_gpos_single(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
                             const otfcc_Options *options) {
	subtable_gpos_single *subtable = &(_subtable->gpos_single);
	gpos_single_hash *h = NULL;
	for (glyphid_t k = 0; k < subtable->length; k++) {
		if (!GlyphOrder.consolidateHandle(font->glyph_order, &subtable->items[k].target)) {
			logWarning("[Consolidate] Ignored missing glyph /%s.\n", subtable->items[k].target.name);
			continue;
		}
		gpos_single_hash *s;
		int fromid = subtable->items[k].target.index;
		HASH_FIND_INT(h, &fromid, s);
		if (s) {
			logWarning("[Consolidate] Detected glyph double-mapping about /%s.\n", subtable->items[k].target.name);
		} else {
			NEW(s);
			s->fromid = subtable->items[k].target.index;
			s->fromname = sdsdup(subtable->items[k].target.name);
			s->v = subtable->items[k].value;
			HASH_ADD_INT(h, fromid, s);
		}
	}

	HASH_SORT(h, gpos_by_from_id);
	iSubtable_gpos_single.clear(subtable);

	gpos_single_hash *s, *tmp;
	HASH_ITER(hh, h, s, tmp) {
		iSubtable_gpos_single.push(subtable,
		                           ((otl_GposSingleEntry){
		                               .target = Handle.fromConsolidated(s->fromid, s->fromname), .value = s->v,
		                           }));
开发者ID:anthrotype,项目名称:otfcc,代码行数:32,代码来源:gpos-single.c


示例8: h3m_add_oa_by_def

int h3m_add_oa_by_def(h3mlib_ctx_t ctx, const char *def, int *oa_index)
{
    struct H3M_OA_ENTRY *oa_entry = NULL;
    struct META_OA_HASH_ENTRY *oa_hash_entry = NULL;
    const struct H3M_OA_BODY *body = NULL;
    int oa_body_index = 0;

    if (NULL == (body = h3m_get_def_body(def, &oa_body_index))) {
        return 1;
    }

    *oa_index = ctx->h3m.oa.count++;
    ctx->h3m.oa.entries = realloc(ctx->h3m.oa.entries,
        sizeof(struct H3M_OA_ENTRY) * ctx->h3m.oa.count);
    oa_entry = &ctx->h3m.oa.entries[ctx->h3m.oa.count - 1];

    oa_entry->header.def_size = strlen(def);
    oa_entry->header.def = (uint8_t *)strdup(def);
    memcpy(&oa_entry->body, body, sizeof(struct H3M_OA_BODY));

    oa_hash_entry = calloc(1, sizeof(*oa_hash_entry));
    oa_hash_entry->def = strdup(def);
    oa_hash_entry->oa_body_index = oa_body_index;
    oa_hash_entry->oa_index = *oa_index;
    HASH_ADD_INT(ctx->meta.oa_hash, oa_body_index, oa_hash_entry);

    return 0;
}
开发者ID:Dergash,项目名称:homm3tools,代码行数:28,代码来源:h3mlib.c


示例9: 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


示例10: main

int main(int argc,char *argv[]) {
    int i;
    example_user_t *user, *users=NULL, *altusers=NULL;

    /* create elements */
    for(i=0;i<1000;i++) {
        if ( (user = (example_user_t*)malloc(sizeof(example_user_t))) == NULL) exit(-1);
        user->id = i;
        user->cookie = i*i;
        if (i<10) HASH_ADD_INT(users,id,user);
        HASH_ADD(alth,altusers,id,sizeof(int),user);
    }

    printf("sorting users ascending\n");
    HASH_SRT(hh,users,ascending_sort);
    for(user=users; user; user=(example_user_t*)user->hh.next)
      printf("user %d\n", user->id);

    printf("sorting altusers descending\n");
    HASH_SRT(alth,altusers,descending_sort);
    for(user=altusers; user; user=(example_user_t*)user->alth.next)
      printf("altuser %d\n", user->id);

    /* HASH_FSCK(hh,users); */
    /* HASH_FSCK(alth,altusers); */
   return 0;
}
开发者ID:RichardOpenGL,项目名称:Bohge_Engine,代码行数:27,代码来源:test19.c


示例11: init_new_client

client_t * init_new_client(agent_t *agent, uuid_t * uuid) 
{
	client_t *new_client; 	
	new_client = calloc(sizeof(client_t),1); 
   if(new_client == NULL) 
   { 
      printf("Malloc failed!\n"); 
      exit(1); 
   } 
   new_client->buffered_packet_table = NULL; 
   new_client->allowed_connections = 0; 
	new_client->agent_sock = calloc(sizeof(int) , agent->options.num_parallel_connections); 
	new_client->agent_side_event_info = calloc(sizeof(struct event_info_struct) ,agent->options.num_parallel_connections); 
   new_client->send_seq = 0; 
   new_client->recv_seq = 0; 


   new_client->agent_fd_poll = calloc(sizeof(char) , agent->options.num_parallel_connections); 
   new_client->num_parallel_connections = 0; 


   new_client->client_hash.client =  new_client; 
   gettimeofday(&new_client->client_hash.accept_start, NULL);
   if(uuid == NULL)
   {
      uuid_generate(new_client->client_hash.id);  
   } 
   else 
   {
      memcpy(new_client->client_hash.id, *uuid, sizeof(uuid_t)); 
   } 
      HASH_ADD_INT(agent->clients_hashes, id, (&new_client->client_hash)); 

	return new_client; 
}
开发者ID:aaronorosen,项目名称:sos-agent,代码行数:35,代码来源:network.c


示例12: adtn_socket_base

static int adtn_socket_base(const char *data_path)
{
	static int UID = 1;
	int sock_id = -1;
	int len;
	bunsock_s *identifier;

	++UID;
	HASH_FIND_INT( sockStore, &sock_id, identifier);
	if (identifier == NULL) {
		sock_id = UID;
		identifier = (bunsock_s *)calloc(1, sizeof(bunsock_s));
		identifier->id = sock_id;
		identifier->sopt.proc_flags = H_DESS | H_NOTF;
		identifier->sopt.block_flags = B_DEL_NP;
		identifier->sopt.lifetime = 100000; //this time is in seconds
		len = strlen(data_path) + 1;
		identifier->data_path = (char *)calloc(len, sizeof(char));
		strncpy(identifier->data_path, data_path, len);
		identifier->bdata = NULL;

		HASH_ADD_INT( sockStore, id, identifier);
	} else {
		errno = EBUSY;
	}

	return sock_id;
}
开发者ID:SeNDA-UAB,项目名称:aDTN-platform,代码行数:28,代码来源:adtn.c


示例13: malloc

stored_object *create_object(size_t size)
{
    stored_object *obj = malloc(sizeof(stored_object));
    uint32_t page_id;

    // initialize to stored_object struct with size and initial pages
    obj->id = current_id++;
    obj->size = 0;
    obj->pages = NULL;

    // add the new object to the objects' hashtable
    HASH_ADD_INT(objects_table, id, obj); 

    while(size > obj->size)
    {
        if (GET_NEW_PAGE(VICTIM_OVERALL, EMPTY_TABLE_ENTRY_NB, &page_id) == FAIL)
        {
            // cleanup just in case we managed to do anything up until now
            remove_object(obj);
            return NULL;
        }

        if(!add_page(obj, page_id))
            return NULL;
        
        // mark new page as valid and used
        UPDATE_NEW_PAGE_MAPPING_NO_LOGICAL(page_id);
    }

    return obj;
}
开发者ID:bkreitch,项目名称:simulator,代码行数:31,代码来源:ftl_obj_strategy.c


示例14: _FTL_OBJ_COPYBACK

int _FTL_OBJ_COPYBACK(int32_t source, int32_t destination)
{
    page_node *source_p;
    
    source_p = lookup_page(source);
    
    // source_p can be NULL if the GC is working on some old pages that belonged to an object we deleted already
    if (source_p != NULL)
    {
        // invalidate the source page
        UPDATE_INVERSE_BLOCK_VALIDITY(CALC_FLASH(source), CALC_BLOCK(source), CALC_PAGE(source), INVALID);
        
        // mark new page as valid and used
        UPDATE_NEW_PAGE_MAPPING_NO_LOGICAL(destination);
        
        // change the object's page mapping to the new page
        HASH_DEL(global_page_table, source_p); 
        source_p->page_id = destination;
        HASH_ADD_INT(global_page_table, page_id, source_p); 
    }
#ifdef FTL_DEBUG
    else
    {
        printf("Warning[%s] %u copyback page not mapped to an object \n", __FUNCTION__, source);
    }
#endif

    return SUCCESS;
}
开发者ID:bkreitch,项目名称:simulator,代码行数:29,代码来源:ftl_obj_strategy.c


示例15: lru_cache_insert

void lru_cache_insert(lru_cache_t* lru,
                      DIR_handle_t handle,
                      struct giga_directory* entry) {
    ACQUIRE_MUTEX(&(lru->mutex_), "lru_cache_insert(%d)", handle);

    // printf("INSERT %d %d, length: %ld, cap: %ld\n", handle, entry->split_flag, lru->length_+1, lru->capacity_);

    struct giga_directory* old;
    HASH_FIND_INT(lru->table, &handle, old);
    if (old != NULL) {
        HASH_DEL(lru->table, old);
        double_list_remove(old);
        lru_cache_unref(old);
    } else {
        ++lru->length_;
    }

    HASH_ADD_INT(lru->table, handle, entry);
    double_list_append(&(lru->dummy), entry);
    entry->refcount = 2;

    while (lru->length_ > lru->capacity_ && lru->dummy.next != &(lru->dummy)) {
        struct giga_directory* old = lru->dummy.next;

        // printf("EVICT ENTRY %d\n", old->handle);

        HASH_DEL(lru->table, old);
        double_list_remove(old);
        lru_cache_unref(old);
        --lru->length_;
    }

    RELEASE_MUTEX(&(lru->mutex_), "lru_cache_insert(%d)", handle);
}
开发者ID:ifcharming,项目名称:mds_scaling,代码行数:34,代码来源:cache.c


示例16: strcpy

hash_token_t *uq_tokenize_to_hash(const char *str, const char *delimiters) {

	unsigned int hash;
	hash_token_t *s, *table = NULL;
	char *tok;
	char tmp[strlen(str) + 1];
	strcpy(tmp, str);

	tok = strtok(tmp, delimiters);

	while(tok != NULL) {

		hash = str_hash(tok);

		HASH_FIND_INT(table, &hash, s);

		if(s == NULL) {

			s = malloc(sizeof(hash_token_t));
			s->key = str_hash(tok);
			s->value = strdup(tok);
			HASH_ADD_INT(table, key, s);

		}

		tok = strtok(NULL, delimiters);

	}

	return (table);

}
开发者ID:aperi2007,项目名称:libsimmetrics,代码行数:32,代码来源:tokenizer.c


示例17: allocate_file_descriptor_table

struct file_descriptor_table * allocate_file_descriptor_table(int pid) {
	struct file_descriptor_table * result_table;

	HASH_FIND_INT(file_descriptor_tables, &pid, result_table);
    
    if (result_table == NULL) {
    	int i;

    	struct file_descriptor_table * table = (struct file_descriptor_table *) malloc(sizeof(struct file_descriptor_table));
    	table->pid = pid;

    	table->entries = (struct file_descriptor_entry *) malloc(8 * sizeof(struct file_descriptor_entry));
    	table->total_descriptors = 8;
    	table->used_descriptors = 3;

    	table->entries[0].fd = 0;
    	table->entries[1].fd = 1;
    	table->entries[2].fd = 2;

    	for (i = 3; i < table->total_descriptors; i++) {
    		table->entries[i].fd = FD_NOT_USED;
    	}
    	
    	HASH_ADD_INT(file_descriptor_tables, pid, table);
    	return table;
    }
    return NULL;
}
开发者ID:gitanuj,项目名称:fstr,代码行数:28,代码来源:syscalls2.c


示例18: add_record

void add_record(char *word, char *filename)
{
  struct Record *r;

  int record_id = djb2((unsigned char *) word);

  HASH_FIND_INT(records, &record_id, r);
  // linear probing to resolve collisions
  while (r != NULL) {
    // found word
    if (strcmp(r->word, word) == 0) {
      break;
    }

    record_id++;
    HASH_FIND_INT(records, &record_id, r);
  }

  if (r == NULL) {
    // found empty spot, proceed to add
    r = (struct Record *)malloc(sizeof(struct Record));
    r->id = record_id;
    r->word = word;
    r->filenames = SLCreate(compareStrings, destroyStrings);
    SLInsert(r->filenames, filename);

    HASH_ADD_INT(records, id, r);
  } else {
    SLInsert(r->filenames, filename);
  }
}
开发者ID:alexandermtang,项目名称:systems_programming,代码行数:31,代码来源:search.c


示例19: main

int main() {
    int i;
    example_user_t *user, *users=NULL, *ausers=NULL, *tmp;

    /* create elements */
    for(i=0;i<10;i++) {
        user = (example_user_t*)m_malloc(sizeof(example_user_t));
        user->id = i;
        HASH_ADD_INT(users,id,user);
    }

    for(user=users; user; user=(example_user_t*)(user->hh.next)) {
        printf("user %d\n", user->id);
    }

    /* now select some users into ausers */
    HASH_SELECT(ah,ausers,hh,users,evens);
    HASH_SRT(ah,ausers,idcmp);

    for(user=ausers; user; user=(example_user_t*)(user->ah.next)) {
        printf("auser %d\n", user->id);
    }
   
	/* free memory */
	HASH_ITER(ah, ausers, user, tmp) {
		HASH_DELETE(ah, ausers, user);     /* delete; users advances to next */
	}
开发者ID:bitfixer,项目名称:bitfixer,代码行数:27,代码来源:test36.c


示例20: sscanf

	void CCBMFontConfiguration::parseKerningEntry(std::string line)
	{		
		//////////////////////////////////////////////////////////////////////////
		// line to parse:
		// kerning first=121  second=44  amount=-7
		//////////////////////////////////////////////////////////////////////////

		// first
		int first;
		int index = line.find("first=");
		int index2 = line.find(' ', index);
		std::string value = line.substr(index, index2-index);
		sscanf(value.c_str(), "first=%d", &first);

		// second
		int second;
		index = line.find("second=");
		index2 = line.find(' ', index);
		value = line.substr(index, index2-index);
		sscanf(value.c_str(), "second=%d", &second);

		// amount
		int amount;
		index = line.find("amount=");
		index2 = line.find(' ', index);
		value = line.substr(index, index2-index);
		sscanf(value.c_str(), "amount=%d", &amount);

		tKerningHashElement *element = (tKerningHashElement *)calloc( sizeof( *element ), 1 );
		element->amount = amount;
		element->key = (first<<16) | (second&0xffff);
		HASH_ADD_INT(m_pKerningDictionary,key, element);
	}
开发者ID:huojian,项目名称:GeniusPeteo,代码行数:33,代码来源:CCLabelBMFont.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HASH_ADD_KEYPTR函数代码示例发布时间:2022-05-30
下一篇:
C++ HASH函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap