本文整理汇总了C++中HashTable::compData方法的典型用法代码示例。如果您正苦于以下问题:C++ HashTable::compData方法的具体用法?C++ HashTable::compData怎么用?C++ HashTable::compData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashTable
的用法示例。
在下文中一共展示了HashTable::compData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HashDelete
int HashDelete(HashTable ht, void *data)
/* Removes the record containing 'data' from ht. If no such record exists,
hashDelete returns 0. On success it returns 1. DOES NOT DESTROY DATA */
{
int retval=0;
HashInfoPtr tmp;
unsigned int hashval = ht->calcIndx(data)%ht->size;
ErrPushFunc("HashDelete");
if(ht->infoArray[hashval]!=NULL) {
if(!(ht->compData(ht->infoArray[hashval]->data, data))) {
HashInfoPtr toTrash; /*First record matched -- remove it! */
toTrash=ht->infoArray[hashval];
ht->infoArray[hashval]=toTrash->next;
#if defined (_POSIX_SEMAPHORES) && defined (_POSIX_THREADS)
{
int error = sem_destroy(&(toTrash->cursorListSemaphore));
if (error != 0)
perror("hash.c HashDelete sem_destroy");
}
#endif
free(toTrash);
ht->elementCount--;
assert( ht->elementCount >= 0 );
retval=1;
}
else {
for( tmp = ht->infoArray[hashval]; /* Continue search for match */
(tmp->next!=NULL) && (ht->compData(tmp->next->data, data));
tmp = tmp->next)
;
if(tmp->next!=NULL) { /* If found, remove the matching record. */
HashInfoPtr toTrash;
toTrash = tmp->next;
tmp->next = toTrash->next;
#if defined (_POSIX_SEMAPHORES) && defined (_POSIX_THREADS)
{
int error = sem_destroy(&(toTrash->cursorListSemaphore));
if (error != 0)
perror("hash.c HashDelete sem_destroy");
}
#endif
free(toTrash);
ht->elementCount--;
assert( ht->elementCount >= 0 );
retval=1;
}
}
}
ErrPopFunc();
return(retval);
}
示例2: HashDestroy
int HashDestroy(HashTable ht, void *data)
/* Removes the record containing 'data' from ht and DESTROYS data.
If no such record exists, it returns 0. On success 1 is returned. */
{
int retval=0;
HashInfoPtr tmp;
unsigned int hashval = ht->calcIndx(data)%ht->size;
ErrPushFunc("HashDestroy");
if(ht->infoArray[hashval]!=NULL) {
if(!(ht->compData(ht->infoArray[hashval]->data, data))) {
HashInfoPtr toTrash; /*First record matched -- remove it! */
toTrash=ht->infoArray[hashval];
ht->infoArray[hashval]=toTrash->next;
DestroyInfo(ht, toTrash);
ht->elementCount--;
assert( ht->elementCount >= 0 );
retval=1;
}
else {
for( tmp = ht->infoArray[hashval]; /* Continue search for match */
(tmp->next!=NULL) && (ht->compData(tmp->next->data, data));
tmp = tmp->next )
;
if(tmp->next!=NULL) { /* If found, remove the matching record. */
HashInfoPtr toTrash;
toTrash = tmp->next;
tmp->next = toTrash->next;
DestroyInfo(ht, toTrash);
ht->elementCount--;
assert( ht->elementCount >= 0 );
retval=1;
}
}
}
ErrPopFunc();
return(retval);
}
示例3: FindInfo
/* Returns the record containing the specified data, NULL if not found */
static HashInfoPtr FindInfo(HashTable ht, void *data, unsigned int hashval)
{
HashInfoPtr tmp;
/* #warning "ErrPushFunc disabled for debugging" */
/* ErrPushFunc("FindInfo"); */
for( tmp=ht->infoArray[hashval];
(tmp!=NULL) && (ht->compData(data, tmp->data));
tmp=tmp->next)
;
/* ErrPopFunc(); */
return(tmp);
}