您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ HASH_ADD_INT函数代码示例

51自学网 2021-06-01 21:22:20
  C++
这篇教程C++ HASH_ADD_INT函数代码示例写得很实用,希望能帮到您。

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

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


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例21: mgr_on_accept

void mgr_on_accept(int fd, event_manager* ev_mgr){    if (internal_threads(ev_mgr->excluded_threads, pthread_self()))        return;    uint32_t leader_id = get_leader_id(ev_mgr->con_node);    if (ev_mgr->node_id == leader_id)    {        leader_tcp_pair* new_conn = malloc(sizeof(leader_tcp_pair));        memset(new_conn,0,sizeof(leader_tcp_pair));        new_conn->key = fd;        HASH_ADD_INT(ev_mgr->leader_tcp_map, key, new_conn);        rsm_op(ev_mgr->con_node, 0, NULL, P_TCP_CONNECT, &new_conn->vs);    } else {        request_record* retrieve_data = NULL;        size_t data_size;            while (retrieve_data == NULL){            retrieve_record(ev_mgr->db_ptr, sizeof(db_key_type), &ev_mgr->cur_rec, &data_size, (void**)&retrieve_data);        }        replica_tcp_pair* ret = NULL;        HASH_FIND(hh, ev_mgr->replica_tcp_map, &retrieve_data->clt_id, sizeof(view_stamp), ret);        ret->s_p = fd;        ret->accepted = 1;    }    return;}
开发者ID:apsys16-p10,项目名称:falcon,代码行数:30,


示例22: main

int main(int argc,char *argv[]) {    int i;    example_user_t *user, *users=NULL, *ausers=NULL;    /* create elements */    for(i=0;i<10;i++) {        user = (example_user_t*)malloc(sizeof(example_user_t));        user->id = i;        HASH_ADD_INT(users,id,user);    }    for(user=users; user!=NULL; user=(example_user_t*)(user->hh.next)) {        printf("user %d/n", user->id);    }    printf("users count: %u/n", HASH_CNT(hh,users));    /* now select some users into ausers */    HASH_SELECT(ah,ausers,hh,users,EVENS);    HASH_SRT(ah,ausers,idcmp);    for(user=ausers; user!=NULL; user=(example_user_t*)(user->ah.next)) {        printf("auser %d/n", user->id);    }    printf("ausers count: %u/n", HASH_CNT(ah,ausers));    HASH_CLEAR(ah,ausers);    printf("cleared ausers./n");    printf("ausers count: %u/n", HASH_CNT(ah,ausers));    for(user=ausers; user!=NULL; user=(example_user_t*)(user->ah.next)) {        printf("auser %d/n", user->id);    }    printf("users count: %u/n", HASH_CNT(hh,users));   return 0;}
开发者ID:gogamejackie,项目名称:uthash,代码行数:33,


示例23: _set_pid

/* Obtain and set a PID for the new process. * O(1) in average case, O(N) degenerate case (more than PID_MAX procs) * Uses hardware FFS instruction, so runs in very quick N/32 time */static int _set_pid(process_create_data *data) {    // Try to increment _last_pid.    int err;    sos_pcb *pcb = data->pcb;    int cur_pid = _last_pid + 1;    sos_pcb *taken = NULL;    if (!pids) {        dprintf(6, "Allocating PID set.../n");        bitset_alloc(&pids, SOS_PID_MAX - SOS_PID_MIN);    }    dprintf(1, "bs size: %d/n", pids->size);    if (bitset_test(pids, cur_pid)) {        dprintf(6, "/tPID %d is already taken./n", cur_pid);        // cur_pid is taken        cur_pid = bitset_ffz(pids);        dprintf(6, "/tfirst free PID: %d/n", cur_pid);        if (cur_pid < 0 || cur_pid > pids->size) {            return SOS_PROCESS_MAXPROC;        }    }    // cur_pid is known to be free    bitset_set(pids, cur_pid);    pcb->pid = cur_pid + SOS_PID_MIN;    _last_pid = cur_pid;    HASH_ADD_INT(_process_table, pid, pcb);    return SOS_PROCESS_SUCCESS;}
开发者ID:thumphries,项目名称:aos,代码行数:34,


示例24: main

int main(int argc,char *argv[]) {    int i;    example_user_t *user, *tmp, *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("hh items: %d, alth items: %d/n",             users->hh.tbl->num_items, users->alth.tbl->num_items);    printf("hh buckets: %d, alth buckets: %d/n",             users->hh.tbl->num_buckets, users->alth.tbl->num_buckets);    */    i=9;    HASH_FIND_INT(users,&i,tmp);    printf("%d %s in hh/n", i, (tmp ? "found" : "not found"));    HASH_FIND(alth,altusers,&i,sizeof(int),tmp);    printf("%d %s in alth/n", i, (tmp ? "found" : "not found"));    i=10;    HASH_FIND_INT(users,&i,tmp);    printf("%d %s in hh/n", i, (tmp ? "found" : "not found"));    HASH_FIND(alth,altusers,&i,sizeof(int),tmp);    printf("%d %s in alth/n", i, (tmp ? "found" : "not found"));   return 0;}
开发者ID:Agyar,项目名称:uthash,代码行数:34,


示例25: main

int main(int argc,char *argv[]) {    int i;    example_user_t *user, *users=NULL, *ausers=NULL;    /* create elements */    for(i=0;i<10;i++) {        user = (example_user_t*)malloc(sizeof(example_user_t));        if (user == NULL) exit(-1);        user->id = i;        HASH_ADD_INT(users,id,user);    }    for(user=users; user!=NULL; 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!=NULL; user=(example_user_t*)(user->ah.next)) {        printf("auser %d/n", user->id);    }   return 0;}
开发者ID:acorbe,项目名称:uthash,代码行数:25,


示例26: CCAssert

void CCActionManager::addAction(CCAction *pAction, CAView *pTarget, bool paused){    CCAssert(pAction != NULL, "");    CCAssert(pTarget != NULL, "");    tHashElement *pElement = NULL;    // we should convert it to CAObject*, because we save it as CAObject*    CAObject *tmp = pTarget;    HASH_FIND_INT(m_pTargets, &tmp, pElement);    if (! pElement)    {        pElement = (tHashElement*)calloc(sizeof(*pElement), 1);        pElement->paused = paused;        pTarget->retain();        pElement->target = pTarget;        HASH_ADD_INT(m_pTargets, target, pElement);    }     actionAllocWithHashElement(pElement);      CCAssert(! ccArrayContainsObject(pElement->actions, pAction), "");     ccArrayAppendObject(pElement->actions, pAction);      pAction->startWithTarget(pTarget);}
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:25,


示例27: main

int main(int argc,char *argv[]) {    int i;    example_user_t *user, *tmp, *users=NULL;    /* create elements */    for(i=0;i<10;i++) {        if ( (user = malloc(sizeof(example_user_t))) == NULL) exit(-1);        user->id = i;        user->cookie = i*i;        HASH_ADD_INT(users,id,user);    }    /* delete each even ID */    for(i=0;i<10;i+=2) {        HASH_FIND_INT(users,&i,tmp);        if (tmp) {            HASH_DEL(users,tmp);            free(tmp);        } else printf("user id %d not found/n", i);    }    i=9;    HASH_FIND_INT(users,&i,tmp);    if (tmp) {        while(tmp) {            printf("id %d, following prev.../n", tmp->id);            tmp = tmp->hh.prev;        }    } else printf("user id %d not found/n", i);}
开发者ID:eriqande,项目名称:snppit,代码行数:31,


示例28: main

int main(int argc,char *argv[]){    int i;    example_user_t *user, *users=NULL;    /* create elements */    for(i=0; i<10; i++) {        user = (example_user_t*)malloc(sizeof(example_user_t));        if (user == NULL) {            exit(-1);        }        user->id = i;        user->cookie = i*i;        HASH_ADD_INT(users,id,user);    }    for(user=users; user != NULL; user=(example_user_t*)user->hh.next) {        printf("user %d, cookie %d/n", user->id, user->cookie);    }    /* delete them all, pathologically */    while(users != NULL) {        printf("deleting id %i/n", users->id);        HASH_DEL(users,users); /* single head/deletee var! */    }    return 0;}
开发者ID:BlueCrystalLabs,项目名称:uthash,代码行数:27,


示例29: main

int main(int argc,char *argv[]) {    int i;    example_user_t *user, *tmp, *users=NULL;    /* create elements */    for(i=0;i<10;i++) {        if ( (user = (example_user_t*)malloc(sizeof(example_user_t))) == NULL)           exit(-1);        user->id = i;        user->cookie = i*i;        HASH_ADD_INT(users,id,user);    }    /* delete each even ID */    for(i=0;i<10;i+=2) {        HASH_FIND_INT(users,&i,tmp);        if (tmp) {            HASH_DEL(users,tmp);            free(tmp);        } else printf("user id %d not found/n", i);    }    /* show the hash */    for(user=users; user != NULL; user=(example_user_t*)(user->hh.next)) {        printf("user %d, cookie %d/n", user->id, user->cookie);    }   return 0;}
开发者ID:AndreaCampagner,项目名称:2014-15,代码行数:28,



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


C++ HASH_ADD_KEYPTR函数代码示例
C++ HASH函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。