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

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

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

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

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

示例1: hash_delete

/******************************************************************* * * Description:     Delete a key in the hash table. * * Modified args:   None * * Return value:    0 if deleted, negative if not found. * *******************************************************************/inthash_delete(HASH_TABLE *ptbl, char *key){    HASH_DATUM key_datum;    struct hash_table_datum *entry;    struct hash_table_datum *prev_entry = NULL;    int index;    key_datum.size = strlen(key) + 1;    key_datum.data = key;        index = HASH(&key_datum);    entry = ((struct hash_table_datum **)ptbl)[index];    while (entry != NULL && (key_datum.size != entry->key.size || (memcmp(key_datum.data, entry->key.data, key_datum.size) != 0)))    {        prev_entry = entry;      /* Keep the previous entry, we need it when unlinking */        entry = entry->next;    }    if (entry != NULL)    {        /* Unlink the old entry, and free memory */        if (prev_entry != NULL)        {            prev_entry->next = entry->next;        }        else        {            /* Old entry was the first in the list */            ((struct hash_table_datum **)ptbl)[index] = entry->next;        }        HASH_FREE(entry);        return 0;    }        return -1;  /* Not found */}
开发者ID:zbh-gitbub,项目名称:ATCA_7400,代码行数:48,


示例2: free

/* allocate the object, creating the object */struct Data *data_alloc( void ) {  struct Data *data;  int index;  if ( (data = malloc( sizeof( struct Data ) )) != NULL ) {    data->count = 1;    if ( pthread_mutex_init( &data->lock, NULL ) != 0 ) {      free( data );      return NULL;    }    index = HASH( data );    pthread_mutex_lock( &tablelock );    data->next = table[ index ];    /* I think it should be = data; */    table[ index ] = data->next;    pthread_mutex_lock( &data->lock );    pthread_mutex_unlock( &tablelock );    data->number = -9999;    pthread_mutex_unlock( data->lock );  }  return data;}
开发者ID:gnanasekarvelu,项目名称:miscellaneous,代码行数:23,


示例3: HTChannel_new

/***	A channel is uniquely identified by a socket.**	Note that we don't create the input and output stream - they are **	created later.****	We only keep a hash on sockfd's as we don't have to look for channels**	for ANSI file descriptors.*/PUBLIC HTChannel * HTChannel_new (SOCKET sockfd, FILE * fp, BOOL active){    HTList * list = NULL;    HTChannel * ch = NULL;    int hash = sockfd < 0 ? 0 : HASH(sockfd);    HTTRACE(PROT_TRACE, "Channel..... Hash value is %d/n" _ hash);    if (!channels) {	if (!(channels = (HTList **) HT_CALLOC(HT_M_HASH_SIZE,sizeof(HTList*))))	    HT_OUTOFMEM("HTChannel_new");    }    if (!channels[hash]) channels[hash] = HTList_new();    list = channels[hash];    if ((ch = (HTChannel *) HT_CALLOC(1, sizeof(HTChannel))) == NULL)	HT_OUTOFMEM("HTChannel_new");	        ch->sockfd = sockfd;    ch->fp = fp;    ch->active = active;    ch->semaphore = 1;    ch->channelIStream.isa = &ChannelIStreamIsa;    ch->channelOStream.isa = &ChannelOStreamIsa;    ch->channelIStream.channel = ch;    ch->channelOStream.channel = ch;    HTList_addObject(list, (void *) ch);#ifdef HT_MUX	    /*	    **  Create a MUX channel and do a connect on this channel with a	    **  new session.	    */	    {		HTProtocol * protocol = HTNet_protocol(net);		HTMuxChannel * muxch = HTMuxChannel_new(me);		net->session = HTMuxSession_connect(muxch, net, HTProtocol_id(protocol));	    }#endif /* HT_MUX */    HTTRACE(PROT_TRACE, "Channel..... Added %p to list %p/n" _ ch _ list);    return ch;}
开发者ID:stefanhusmann,项目名称:Amaya,代码行数:47,


示例4: PREFIXED

/* Note that even the slow path doesn't lock.	*/void *  PREFIXED(slow_getspecific) (tsd * key, unsigned long qtid,				    tse * volatile * cache_ptr) {    pthread_t self = pthread_self();    unsigned hash_val = HASH(self);    tse *entry = key -> hash[hash_val];    GC_ASSERT(qtid != INVALID_QTID);    while (entry != NULL && entry -> thread != self) {	entry = entry -> next;    }     if (entry == NULL) return NULL;    /* Set cache_entry.		*/        entry -> qtid = qtid;		/* It's safe to do this asynchronously.  Either value 	*/		/* is safe, though may produce spurious misses.		*/		/* We're replacing one qtid with another one for the	*/		/* same thread.						*/	*cache_ptr = entry;		/* Again this is safe since pointer assignments are 	*/		/* presumed atomic, and either pointer is valid.	*/    return entry -> value;}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:23,


示例5: HASH_UNCHECKED

// ------------------------------------------------------------------size_t __checked_pointer_table::getSize(const void* address){	int index = HASH_UNCHECKED(address);	__node* node = uncheckedTable[index];	while((node != 0) && (node->address != address))		node = node->next;	if(node != 0)		return node->size;	index = HASH(address);	node = table[index];	while((node != 0) && (node->address != address))		node = node->next;	if(node != 0)				return node->size;	return (size_t)-1;}
开发者ID:edpack1980,项目名称:uml-auto-assessment,代码行数:23,


示例6: initialize

/* - initialize - hand-craft a cache entry for startup, otherwise get ready ^ static struct sset *initialize(struct vars *, struct dfa *, chr *); */static struct sset *initialize(    struct vars *v,		/* used only for debug flags */    struct dfa *d,    chr *start){    struct sset *ss;    int i;    /*     * Is previous one still there?     */    if (d->nssused > 0 && (d->ssets[0].flags&STARTER)) {	ss = &d->ssets[0];    } else {			/* no, must (re)build it */	ss = getvacant(v, d, start, start);	for (i = 0; i < d->wordsper; i++) {	    ss->states[i] = 0;	}	BSET(ss->states, d->cnfa->pre);	ss->hash = HASH(ss->states, d->wordsper);	assert(d->cnfa->pre != d->cnfa->post);	ss->flags = STARTER|LOCKED|NOPROGRESS;	/*	 * lastseen dealt with below	 */    }    for (i = 0; i < d->nssused; i++) {	d->ssets[i].lastseen = NULL;    }    ss->lastseen = start;	/* maybe untrue, but harmless */    d->lastpost = NULL;    d->lastnopr = NULL;    return ss;}
开发者ID:AbaqusPowerUsers,项目名称:AbaqusPythonScripts,代码行数:42,


示例7: foo_alloc

struct foo *foo_alloc(void) /* allocate the object */{	struct foo	*fp;	int			idx;	if ((fp = malloc(sizeof(struct foo))) != NULL) {		fp->f_count = 1;		if (pthread_mutex_init(&fp->f_lock, NULL) != 0) {			free(fp);			return(NULL);		}		idx = HASH(fp);		pthread_mutex_lock(&hashlock);		fp->f_next = fh[idx];		fh[idx] = fp->f_next;		pthread_mutex_lock(&fp->f_lock);		pthread_mutex_unlock(&hashlock);		/* ... continue initialization ... */		pthread_mutex_unlock(&fp->f_lock);	}	return(fp);}
开发者ID:snskshn,项目名称:code_segments,代码行数:23,


示例8: fooRele

void fooRele(struct Foo *fp){    struct Foo *tfp;    int idx;        pthread_mutex_lock(&hashLock);    if(-- fp -> fCount == 0){        idx = HASH(fp -> fId);        tfp = fh[idx];        if(tfp == fp){            fh[idx] = fp -> fNext;        }else{            while(tfp -> fNext != fp){                tfp = tfp -> fNext;            }            tfp -> fNext = fp -> fNext;        }        pthread_mutex_unlock(&hashLock);        pthread_mutex_destroy(&fp -> fLock);        free(fp);    }else{        pthread_mutex_unlock(&hashLock);    }}
开发者ID:chenfan2014,项目名称:CFgit,代码行数:23,


示例9: __pspgl_hash_insert

void __pspgl_hash_insert (struct hashtable *h, unsigned long key, void *value){	unsigned long b = HASH(key);	struct hashentry *ent;	if (key <= h->maxkey) {		for (ent=h->buckets[b]; ent!=NULL; ent=ent->next) {			if (ent->key == key) {				ent->data = value;				return;			}		}	}	if ((ent = malloc(sizeof(*ent)))) {		ent->key = key;		ent->data = value;		ent->next = h->buckets[b];		h->buckets[b] = ent;		if (key > h->maxkey)			h->maxkey = key;	}}
开发者ID:Bracket-,项目名称:psp-ports,代码行数:23,


示例10: kvs_get

/* * returned value is not dup-ed */extern char *kvs_get(char *key){	kvs_bucket_t *bucket;	char *val = NULL;	int i;	debug3("mpi/pmi2: in kvs_get, key=%s", key);	bucket = &kvs_hash[HASH(key)];	if (bucket->count > 0) {		for(i = 0; i < bucket->count; i ++) {			if (! xstrcmp(key, bucket->pairs[KEY_INDEX(i)])) {				val = bucket->pairs[VAL_INDEX(i)];				break;			}		}	}	debug3("mpi/pmi2: out kvs_get, val=%s", val);	return val;}
开发者ID:SchedMD,项目名称:slurm,代码行数:26,


示例11: hash_insert

inthash_insert (    void       *el,    hashtab    *htab){    int         i;    hashnode   *hnode;    ++htab->cardinal;    if (htab->cardinal > htab->size * 10)    {        restructure (htab);    }    hnode = new hashnode[sizeof (*hnode)];    if (hnode == NULL)        return 1;    i = HASH (htab, el);    hnode->next = htab->vec[i];    hnode->el = el;    htab->vec[i] = hnode;    return 0;}
开发者ID:arlukin,项目名称:dev,代码行数:23,


示例12: SearchStructure

//-----------------------------------------------------------------//// Function:   SearchStructure//// Purpose:    Searches the profiler data struture for the function//             name.//// Input:      Profile  -  pointer to profiler data structure//             Symbol   -  pointer to name to search  for//// Output:     SProfileRecord  -  pointer to the entry that contains//                                the name, Symbol, if found.  Otherwise//                                NULL is returned.////------------------------------------------------------------------SProfileRecord * SearchStructure (SProfile *Profile, UCHAR *Symbol){   unsigned long cHashNumber;   unsigned long iBucket;   SProfileRecord *pProfileRecord;   // Hash on the first + last letters of the symbol   cHashNumber = (unsigned long)Symbol[0] + (unsigned long)Symbol[strlen(Symbol)-1];   iBucket = HASH(cHashNumber);   // Search the bucket for the corresponding entry   pProfileRecord = Profile->Buckets[iBucket];   while (pProfileRecord != NULL)   {      if (!strcmp(pProfileRecord->Symbol, Symbol))         break;      else         pProfileRecord = pProfileRecord->pNext;   }   return (pProfileRecord);}
开发者ID:mingpen,项目名称:OpenNT,代码行数:38,


示例13: pxdns_request_find

/** * Find request by the id we used when relaying it and remove it from * id hash and timeout list.  Called from pxdns_pmgr_pump() when reply * comes. */static struct request *pxdns_request_find(struct pxdns *pxdns, u16_t id){    struct request *req = NULL;    sys_mutex_lock(&pxdns->lock);    /* find request in the id->req hash */    for (req = pxdns->request_hash[HASH(id)]; req != NULL; req = req->next_hash) {        if (req->id == id) {            break;        }    }    if (req != NULL) {        pxdns_hash_del(pxdns, req);        pxdns_timeout_del(pxdns, req);        --pxdns->active_queries;    }    sys_mutex_unlock(&pxdns->lock);    return req;}
开发者ID:bayasist,项目名称:vbox,代码行数:28,


示例14: free

struct Foo *fooAlloc(int id){    struct Foo *fp;    int idx;    if((fp = (Foo *)malloc(sizeof(struct Foo))) != NULL){        fp -> fCount = 1;        fp -> fId = id;        if(pthread_mutex_init(&fp -> fLock, NULL) != 0){            free(fp);            return NULL;        }        idx = HASH(id);        pthread_mutex_lock(&hashLock);        fp -> fNext = fh[idx];        fh[idx] = fp;        pthread_mutex_lock(&fp -> fLock);        pthread_mutex_unlock(&hashLock);        pthread_mutex_unlock(&fp -> fLock);    }    return fp;}
开发者ID:chenfan2014,项目名称:CFgit,代码行数:23,


示例15: update

    ///----------------------------------------------------------------------------//    ///--------------------- UPDATE SECTION ---------------------------------------//    ///----------------------------------------------------------------------------//    Scene::Enum update(float dt) override {        Entity animLogo = e(HASH("logo/logo_anim", 0xed78c546));        if (timeAccum > 0.8 + 0.05 + 0.25 + 0.05) {            RENDERING(animLogo)->show = false;            return Scene::Menu;        } else if (timeAccum > 0.8 + 0.05 + 0.25) {            RENDERING(animLogo)->texture = theRenderingSystem.loadTextureFile("soupe_logo2_365_331");        }        else if (timeAccum > 0.8 + 0.05) {            if (!soundPlayed) {                SOUND(animLogo)->sound = theSoundSystem.loadSoundFile("sounds/logo_blink.ogg");                soundPlayed = true;            }            RENDERING(animLogo)->texture = theRenderingSystem.loadTextureFile("soupe_logo3_365_331");        }        else if (timeAccum > 0.8) {            RENDERING(animLogo)->show = true;        }        timeAccum += dt;        return Scene::Logo;    }
开发者ID:SoupeauCaillou,项目名称:recursive-runner,代码行数:26,


示例16: GC_remove_specific

/* thread exit.                                                         */GC_INNER void GC_remove_specific(tsd * key){    pthread_t self = pthread_self();    unsigned hash_val = HASH(self);    tse *entry;    tse **link = &key->hash[hash_val].p;    pthread_mutex_lock(&(key -> lock));    entry = *link;    while (entry != NULL && entry -> thread != self) {      link = &(entry -> next);      entry = *link;    }    /* Invalidate qtid field, since qtids may be reused, and a later    */    /* cache lookup could otherwise find this entry.                    */    if (entry != NULL) {      entry -> qtid = INVALID_QTID;      *link = entry -> next;      /* Atomic! concurrent accesses still work.        */      /* They must, since readers don't lock.           */      /* We shouldn't need a volatile access here,      */      /* since both this and the preceding write        */      /* should become visible no later than            */      /* the pthread_mutex_unlock() call.               */    }    /* If we wanted to deallocate the entry, we'd first have to clear   */    /* any cache entries pointing to it.  That probably requires        */    /* additional synchronization, since we can't prevent a concurrent  */    /* cache lookup, which should still be examining deallocated memory.*/    /* This can only happen if the concurrent access is from another    */    /* thread, and hence has missed the cache, but still...             */    /* With GC, we're done, since the pointers from the cache will      */    /* be overwritten, all local pointers to the entries will be        */    /* dropped, and the entry will then be reclaimed.                   */    pthread_mutex_unlock(&(key -> lock));}
开发者ID:jisqyv,项目名称:bdwgc,代码行数:38,


示例17: idf_hashed

Tokenidf_hashed(const char *str) {	int32 h = 0;	/* let's be careful about ranges; if done wrong it's hard to debug */	while (*str) {		int ch = *str++ & 0377;		/* ignore spaces in spaced words */		if (ch == ' ') continue;		/* -1 <= h <= 2^31-1 */		h = HASH(h, ch);		/* -2^31 <= h <= 2^31-1 */		if (h < 0) {			/* -2^31 <= h <= -1 */			h += 2147483647;	/* 2^31-1 */			/* -1 <= h <= 2^31-2 */		}		else {			/* 0 <= h <= 2^31-1 */		}		/* -1 <= h <= 2^31-1 */	}	/* -1 <= h <= 2^31-1 */	if (h < 0) {		/* h = -1 */		h = 0;	}	/* 0 <= h <= 2^31-1 */	h %= (N_TOKENS - N_REGULAR_TOKENS - 1);	/* 0 <= h < N_TOKENS - N_REGULAR_TOKENS - 1 */	h += N_REGULAR_TOKENS;	/* N_REGULAR_TOKENS <= h < N_TOKENS - 1 */	return int2Token(h);	/* this avoids the regular tokens and End_Of_Line */}
开发者ID:B88000005,项目名称:RunServer,代码行数:37,


示例18: data_release

/* release a reference to the object */void data_release( struct Data *data ) {  struct Data *tmp;  int index;  pthread_mutex_lock( &data->lock );  if ( data->count == 1 ) {    /* it is the last reference */    pthread_mutex_unlock( &data->lock );    pthread_mutex_lock( &tablelock );    pthread_mutex_lock( &data->lock );    /* need to recheck the condition */    if ( data->count != 1 ) {      data->count--;      pthread_mutex_unlock( &data->lock );      pthread_mutex_unlock( &tablelock );      return;    }    /* remove it from list */    index = HASH( data );    tmp = table[ index ];    if ( tmp == data ) {      table[ index ] = data->next;    } else {      while ( tmp->next != data ) {	tmp = data->next;      }      tmp->next = data->next;    }    pthread_mutex_unlock( &tablelock );    pthread_mutex_unlock( &data->lock );    pthread_mutex_destroy( &data->lock );    free( data );  } else {    data->count--;    pthread_mutex_unlock( &data->lock );  }}
开发者ID:gnanasekarvelu,项目名称:miscellaneous,代码行数:38,


示例19: hashset_add

int hashset_add(hashset_p set, const void *item, size_t bytes){	slot_p slot = NULL, new_slot = NULL;	slotlist_p slotlist = &set->slotlists[HASH(set, item, bytes) % set->slotlists_n];	slot_p *pslot = &slotlist->list;	int is_new = !(slot = *pslot);	while (slot) {		if (!CMP(set, &slot->data, item, bytes)) {			return -1;		}		pslot = &slot->next;		slot = *pslot;	}	*pslot = new_slot = (slot_p) malloc(bytes + sizeof(slot_p));	if (!new_slot) {		return -2;	}	new_slot->next = NULL;	memcpy(&new_slot->data, item, bytes);	if (!set->non_null) {		set->non_null = slotlist;	} else if (is_new) {		set->non_null->pre = slotlist;		slotlist->next = set->non_null;		set->non_null = slotlist;	}	++set->size;	return 0;}
开发者ID:nicky-zs,项目名称:dbscan,代码行数:37,


示例20: foo_rele

voidfoo_rele(struct foo *fp) /* release a reference to the object */{	struct foo	*tfp;	int			idx;	pthread_mutex_lock(&fp->f_lock);	if (fp->f_count == 1) { /* last reference */		pthread_mutex_unlock(&fp->f_lock);		pthread_mutex_lock(&hashlock);		pthread_mutex_lock(&fp->f_lock);		/* need to recheck the condition */		if (fp->f_count != 1) {			fp->f_count--;			pthread_mutex_unlock(&fp->f_lock);			pthread_mutex_unlock(&hashlock);			return;		}		/* remove from list */		idx = HASH(fp);		tfp = fh[idx];		if (tfp == fp) {			fh[idx] = fp->f_next;		} else {			while (tfp->f_next != fp)			tfp = tfp->f_next;			tfp->f_next = fp->f_next;		}		pthread_mutex_unlock(&hashlock);		pthread_mutex_unlock(&fp->f_lock);		pthread_mutex_destroy(&fp->f_lock);		free(fp);		} else {			fp->f_count--;			pthread_mutex_unlock(&fp->f_lock);		}}
开发者ID:vonzhou,项目名称:Coding,代码行数:37,


示例21: hash_del2

void hash_del2 (    char *name,    char *type,    HashTable_t *ht){    char *me = "hash_del2";    int  hashval;    HashElm_t *prev_ptr = NULL;    HashElm_t *curr_ptr;    if ((ht == NULL) || (ht->tbl == NULL)) {        return;    }    HASH(hashval,ht,name);    curr_ptr = ht->tbl[hashval];    while (curr_ptr != NULL) {        if (strcmp(name, curr_ptr->name) == 0) {            if (strcmp(type, curr_ptr->type) != 0)  {                fprintf(stderr,"%s: hash library PROGRAMMER ERROR - types do not match/n",me);                exit(EXIT_FAILURE);            }            if (prev_ptr == NULL) {                ht->tbl[hashval]   = curr_ptr->next;            }            else                  {                prev_ptr->next = curr_ptr->next;            }            FREEMEM(curr_ptr->name);            FREEMEM(curr_ptr->type);            FREEMEM(curr_ptr);            break;        }        else {            prev_ptr = curr_ptr;            curr_ptr = curr_ptr->next;        }    }}
开发者ID:tpatki,项目名称:sequoia,代码行数:37,


示例22: SockEvents_get

PRIVATE SockEvents * SockEvents_get (SOCKET s, SockEvents_action action){    long v = HASH(s);    HTList* cur;    SockEvents * pres;    /* if the socket doesn't exists, don't do anything */    if (s == INVSOC)      return NULL;    if (HashTable[v] == NULL) HashTable[v] = HTList_new();    cur = HashTable[v];    while ((pres = (SockEvents *) HTList_nextObject(cur)))	if (pres->s == s) return pres;    if (action == SockEvents_mayCreate) {        if ((pres = (SockEvents *) HT_CALLOC(1, sizeof(SockEvents))) == NULL)	    HT_OUTOFMEM("HTEventList_register");	pres->s = s;	HTList_addObject(HashTable[v], (void *)pres);	return pres;    }    return NULL;}
开发者ID:ChatanW,项目名称:WebDaM,代码行数:24,


示例23: compress

static intcompress(struct pred1_state *state, u_char *source, u_char *dest, int len){    int i, bitmask;    unsigned char *flagdest, flags, *orgdest;    orgdest = dest;    while (len) {        flagdest = dest++;        flags = 0;			/* All guess wrong initially */        for (bitmask = 1, i = 0; i < 8 && len; i++, bitmask <<= 1) {            if (state->dict[state->hash] == *source) {                flags |= bitmask;	/* Guess was right - don't output */            } else {                state->dict[state->hash] = *source;                *dest++ = *source;	/* Guess wrong, output char */            }            HASH(state, *source++);            len--;        }        *flagdest = flags;    }    return (dest - orgdest);}
开发者ID:cyrilmagsuci,项目名称:freebsd,代码行数:24,


示例24: foo_rele

void foo_rele(struct foo *fp){  struct foo *tfp;  int idx;    pthread_mutex_lock(&fp->f_lock);  if(fp->f_count==1){    printf("f_count=1/n");    pthread_mutex_unlock(&fp->f_lock);    pthread_mutex_lock(&hashlock);    pthread_mutex_lock(&fp->f_lock);    if(fp->f_count!=1){      fp->f_count--;      pthread_mutex_unlock(&fp->f_lock);      pthread_mutex_unlock(&hashlock);      return;    }        idx=HASH(fp->f_id);    tfp=fh[idx];    if(tfp==fp){      fh[idx]==fp->f_next;    }else{      while(tfp->f_next!=fp)	tfp=tfp->f_next;      tfp->f_next = fp->f_next;    }        pthread_mutex_unlock(&hashlock);    pthread_mutex_unlock(&fp->f_lock);    pthread_mutex_destroy(&fp->f_lock);    free(fp);  }else{    fp->f_count--;    pthread_mutex_unlock(&fp->f_lock);  }}
开发者ID:xiaobudongzhang,项目名称:lib,代码行数:36,


示例25: instance_get_by_type

INSTANCE * instance_get_by_type( uint32_t type, INSTANCE ** context ){    INSTANCE * i;    if ( !context || !hashed_by_type || !type /* || type >= FIRST_INSTANCE_ID */ ) return NULL;    if ( !*context ) /* start scan */        i = hashed_by_type[HASH( type )];    else if ( ( i = *context ) == ( INSTANCE * ) -1 ) /* End scan */        return ( *context = NULL );    if ( i ) /* Valid instance, continue scan */    {        if ( i->next_by_type )            *context = i->next_by_type ;        else            *context = ( INSTANCE * ) -1 ; /* Next call will be "end scan" */        return i;    }    /* Here only if hashed_by_type[HASH( type )] is NULL */    return ( *context = NULL ) ; /* return is null, then end scan */}
开发者ID:segafan,项目名称:bennugd-monolithic,代码行数:24,


示例26: block

/* =============================================================================   Function:		AddBlk		// local //   Author:		Rammi   Date:		16.11.1995   Return:		---   Parameter:		Blk		New block (original pos.)			file		called from   Purpose:		Add new block to the list   ============================================================================= */static void AddBlk(begin *Blk, const char *file){  int hash = HASH(Blk);		/* hash val */  /* make sure everything is initialized */  if (!Global.isInitialized) {    Initialize();  }#if RM_TEST_DEPTH > 1  TestAll(file);#else  /* prevent compiler warnings about unused variables */  file = NULL;#endif  /* --- insert it --- */  Blk->Next = Chain[hash].Next;  Blk->Prev = &Chain[hash];  Chain[hash].Next->Prev = Blk;  Chain[hash].Next = Blk;  Global.BlockCount++;}
开发者ID:ellis2323,项目名称:peopsgpu,代码行数:35,


示例27: declaredLocally

int declaredLocally(char* symbolName){    int hashIndex = HASH(symbolName);    SymbolTableEntry* hashChain = symbolTable.hashTable[hashIndex];    while(hashChain)    {        if(strcmp(hashChain->name, symbolName) == 0)        {            if(hashChain->nestingLevel == symbolTable.currentLevel)            {                return 1;            }            else            {                return 0;            }        }        else        {            hashChain = hashChain->nextInHashChain;        }    }    return 0;}
开发者ID:haiwei624,项目名称:data,代码行数:24,


示例28: GC_setspecific

/* Called with the lock held.   */GC_INNER int GC_setspecific(tsd * key, void * value){    pthread_t self = pthread_self();    int hash_val = HASH(self);    volatile tse * entry;    GC_ASSERT(self != INVALID_THREADID);    GC_dont_gc++; /* disable GC */    entry = (volatile tse *)MALLOC_CLEAR(sizeof(tse));    GC_dont_gc--;    if (0 == entry) return ENOMEM;    pthread_mutex_lock(&(key -> lock));    /* Could easily check for an existing entry here.   */    entry -> next = key->hash[hash_val].p;    entry -> thread = self;    entry -> value = value;    GC_ASSERT(entry -> qtid == INVALID_QTID);    /* There can only be one writer at a time, but this needs to be     */    /* atomic with respect to concurrent readers.                       */    AO_store_release(&key->hash[hash_val].ao, (AO_t)entry);    pthread_mutex_unlock(&(key -> lock));    return 0;}
开发者ID:jisqyv,项目名称:bdwgc,代码行数:25,


示例29: HASH

/*! * /internal * /brief Remove a region from the active regions. * * /param ptr Region payload data pointer. * * /retval region on success. * /retval NULL if not found. */static struct ast_region *region_remove(void *ptr){	int hash;	struct ast_region *reg;	struct ast_region *prev = NULL;	hash = HASH(ptr);	ast_mutex_lock(&reglock);	for (reg = regions[hash]; reg; reg = AST_LIST_NEXT(reg, node)) {		if (reg->data == ptr) {			if (prev) {				AST_LIST_NEXT(prev, node) = AST_LIST_NEXT(reg, node);			} else {				regions[hash] = AST_LIST_NEXT(reg, node);			}			break;		}		prev = reg;	}	ast_mutex_unlock(&reglock);	return reg;}
开发者ID:litnimax,项目名称:asterisk,代码行数:33,


示例30: foo_rele

voidfoo_rele (struct foo *fp) /* release a reference to the object */{    struct foo * tfp;    int idx;    pthread_mutex_lock(&hashlock);    if(--fp ->f_count == 0){ /* last reference, remove from list */        idx = HASH(fp);        tfp = fh[idx];        if(tfp == fp){            fh[idx] = fp->f_next;        }else{            while(tfp->f_next !=fp)                tfp = tfp -> f_next;            tfp->f_next = fp->f_next;        }        pthread_mutex_unlock(&hashlock);        pthread_mutex_destroy(&fp -> f_lock);        free(fp);    } else{        pthread_mutex_unlock(&hashlock);    }}
开发者ID:quake0day,项目名称:APUE_code_pratice,代码行数:24,



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


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