本文整理汇总了C++中destroyList函数的典型用法代码示例。如果您正苦于以下问题:C++ destroyList函数的具体用法?C++ destroyList怎么用?C++ destroyList使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了destroyList函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: destroyList
void destroyList(Node * head)
{
Node * n = head->next;
free(head);
if(n != NULL)
destroyList(n);
}
示例2: main
int main(int argc, char** argv)
{
switch(argc) {
case 5:
LIST_LEN = (1<<atoi(argv[4]));
case 4:
TOTAL_LISTS = (1<<atoi(argv[3]));
case 3:
REPEAT_TIMES = atoi(argv[2]);
case 2:
TOGETHER_NUM = atoi(argv[1]);
break;
default:
break;
}
int syscpu = sysconf(_SC_NPROCESSORS_CONF);
int processorid = 0;
cpu_set_t mask;
CPU_ZERO(&mask);
CPU_SET(processorid, &mask);
if (sched_setaffinity(0, sizeof(mask), &mask) == -1) {
std::cerr << "could not set CPU affinity in main thread " << std::endl;
}
#ifdef USING_MALLOC
head = (List**)malloc(TOTAL_LISTS*sizeof(List*));
allList = (List**)malloc(TOTAL_LISTS*sizeof(List*));
listsLen = (int*)malloc(TOTAL_LISTS*sizeof(int));
listNumber = (int*)malloc(TOTAL_LISTS*sizeof(int));
#else
head = new List*[TOTAL_LISTS];
allList = new List*[TOTAL_LISTS];
listsLen = new int[TOTAL_LISTS];
listNumber = new int[TOTAL_LISTS];
#endif
gettimeofday(&start, NULL);
buildList();
gettimeofday(&end, NULL);
double duration = (end.tv_sec-start.tv_sec) + (end.tv_usec-start.tv_usec)/1000000.0;
std::cerr << "build duration = " << duration << std::endl;
gettimeofday(&start, NULL);
int loopNum = TOTAL_LISTS/TOGETHER_NUM;
if (TOTAL_LISTS%TOGETHER_NUM != 0) {
loopNum++;
}
for (int i = 0; i < loopNum; i++) {
tracingTask(i);
}
gettimeofday(&end, NULL);
duration = (end.tv_sec-start.tv_sec) + (end.tv_usec-start.tv_usec)/1000000.0;
std::cout << "traverse duration " << duration << " s" << std::endl;
std::cerr << "traverse duration " << duration << " s accum " << total_accum << " traverse " << tra_times << std::endl;
destroyList();
return 0;
}
示例3: destroyList
void MIDIOut::rescanDevices()
{
/* Treat all devices nonexistent and doomed for destruction */
QList <MIDIDevice*> destroyList(m_devices);
/* Find out which devices are still present */
for (ItemCount i = 0; i < MIDIGetNumberOfDevices(); i++)
{
MIDIDeviceRef dev = MIDIGetDevice(i);
for (ItemCount j = 0; j < MIDIDeviceGetNumberOfEntities(dev); j++)
{
MIDIEntityRef entity = MIDIDeviceGetEntity(dev, j);
OSStatus s = 0;
SInt32 uid = 0;
/* Check if the entity is able to send data */
if (MIDIEntityGetNumberOfDestinations(entity) == 0)
continue;
/* Extract UID from the entity */
s = MIDIObjectGetIntegerProperty(entity, kMIDIPropertyUniqueID, &uid);
if (s != 0)
{
qWarning() << "Unable to get entity UID";
continue;
}
MIDIDevice* dev(deviceByUID(uid));
if (dev != NULL)
{
/* Device still exists */
destroyList.removeAll(dev);
}
else
{
/* New device */
dev = new MIDIDevice(this, entity);
Q_ASSERT(dev != NULL);
if (dev->extractUID() == true &&
dev->extractName() == true)
{
addDevice(dev);
}
else
{
delete dev;
dev = NULL;
}
}
}
}
/* Destroy all devices that were no longer present */
while (destroyList.isEmpty() == false)
delete destroyList.takeFirst();
}
示例4: destroyList
int destroyList( listOfPaths_t* list)
{
if (list != NULL)
{
if (list->next != NULL) destroyList(list->next);
free(list->path);
free(list);
}
return 1;
}
示例5: searchExactManyCoresK
// Exact k-NN search with the RBC. This version works better on computers
// with a high core count (say > 4)
void searchExactManyCoresK(matrix q, matrix x, matrix r, rep *ri, unint **NNs, real **dNNs, unint K){
unint i, j, k;
unint **repID = (unint**)calloc(q.pr, sizeof(*repID));
for(i=0; i<q.pr; i++)
repID[i] = (unint*)calloc(K, sizeof(**repID));
real **dToReps = (real**)calloc(q.pr, sizeof(*dToReps));
for(i=0; i<q.pr; i++)
dToReps[i] = (real*)calloc(K, sizeof(**dToReps));
intList *toSearch = (intList*)calloc(r.pr, sizeof(*toSearch));
for(i=0;i<r.pr;i++)
createList(&toSearch[i]);
bruteKHeap(r,q,repID,dToReps,K);
#pragma omp parallel for private(j,k)
for(i=0; i<r.pr/CL; i++){
unint row = CL*i;
real temp[CL];
for(j=0; j<q.r; j++ ){
for(k=0; k<CL; k++){
temp[k] = distVec( q, r, j, row+k );
}
for(k=0; k<CL; k++){
//dToRep[j] is current UB on dist to j's NN
//temp - ri[i].radius is LB to dist belonging to rep i
if( row+k<r.r && 3.0*dToReps[j][K-1] >= temp[k] && dToReps[j][K-1] >= temp[k] - ri[row+k].radius)
addToList(&toSearch[row+k], j); //query j needs to search rep
}
}
for(j=0;j<CL;j++){
if(row+j<r.r){
while(toSearch[row+j].len % CL != 0)
addToList(&toSearch[row+j],DUMMY_IDX);
}
}
}
bruteListK(x,q,ri,toSearch,r.r,NNs,dToReps,K);
for(i=0; i<q.r; i++){
for(j=0; j<K; j++)
dNNs[i][j]=dToReps[i][j];
}
for(i=0;i<q.pr;i++)
free(dToReps[i]);
free(dToReps);
for(i=0;i<r.pr;i++)
destroyList(&toSearch[i]);
free(toSearch);
for(i=0;i<q.pr;i++)
free(repID[i]);
free(repID);
}
示例6: main
int main()
{
int a = 0;
int b = 0;
int tmp = 0;
List* listLess = createList();
List* listBetween = createList();
List* listMore = createList();
printf("Enter a\n");
scanf("%d",&a);
printf("Enter b \n");
scanf("%d",&b);
FILE* f = fopen("input.txt","r");
FILE* g = fopen("output.txt","w");
while (!(feof(f)))
{
fscanf(f,"%d",&tmp);
if (tmp < a)
add(listLess,tmp);
if ((a <= tmp) && (tmp <= b))
add(listBetween,tmp);
if (tmp >= b)
add(listMore,tmp);
}
printListToFile(listLess,g);
fprintf(g," | ");
printListToFile(listBetween,g);
fprintf(g," | ");
printListToFile(listMore,g);
destroyList(listLess);
destroyList(listBetween);
destroyList(listMore);
fclose(f);
fclose(g);
printf("See output file\n");
getc(stdin);
}
示例7: applyChanges
void applyChanges(int *board,int w)
{
Node *information;
int i;
for(i=1;i<=statusList.size;i++)
{
information=searchByPos(&statusList,i);
board[information->data->i*w+information->data->j]=information->data->status;
}
destroyList(&statusList);
}
示例8: destroyList
//Completely free a list
void destroyList(VyNode* node, int destroyData)
{
//Make sure a node is declared
if(node == NULL)
return;
//Destroy the data
if(node->data != NULL && destroyData)
free(node->data);
//Recursilvy call this function
destroyList(node->nextNode,destroyData);
}
示例9: destroyList
typename Particles<ParticleTraits>::Size_t
Particles<ParticleTraits>::deferredDestroyAmount(PatchID_t pid) const
{
Size_t retval = 0;
// Add in all relevant sizes
if (pid < 0)
{
PatchID_t i, npatch = attributeLayout_m.sizeLocal();
for (i = 0; i < npatch; ++i)
retval += destroyList(i).domain().size();
}
else
{
retval = destroyList(pid).domain().size();
}
return retval;
}
示例10: destroyList
void TdmCurrentState::createSkillList(void){
//Очистить список
destroyList(skillList, etSKILL);
skillMap.clear();
skillList = TSkill::getAll();
//Создать индексированный список
for(int i=0; i < skillList->Count; i++){
TSkill *current = (TSkill*)skillList->Items[i];
skillMap[current->getId()] = current;
}
}
示例11: ddcSeaStatsShowTimeDiff
void ddcSeaStatsShowTimeDiff(){
Node* node = timeList;
while(node != NULL){
TimeDiff* diff = (TimeDiff*)(node->data);
fprintf(stderr,",%lu", (unsigned long)(diff->end.tv_usec - diff->start.tv_usec));
node = node->next;
}
fprintf(stderr, "\n");
destroyList(timeList);
}
示例12: destroyChnTbl
/*------------------------------------------------------------------------------
*name: destroyChnTbl()
*arguments: ChnTbl *chntbl
*return: void
*exception:
*functions: 销毁哈希链表
*----------------------------------------------------------------------------*/
void destroyChnTbl(ChnTbl *chntbl)
{
for (int i = 0; i < chntbl->key_num; ++i)
{
destroyList(&chntbl->key_lists[i]);
}
free(chntbl->key_lists);
memset(chntbl, 0, sizeof(ChnTbl));
}
示例13: main
int main(int argc, char** argv)
{
switch(argc) {
case 5:
LIST_LEN = (1<<atoi(argv[4]));
case 4:
TOTAL_LISTS = (1<<atoi(argv[3]));
case 3:
REPEAT_TIMES = atoi(argv[2]);
case 2:
CORO_NUM = atoi(argv[1]);
break;
default:
break;
}
int syscpu = sysconf(_SC_NPROCESSORS_CONF);
int quarterCore = syscpu/4;
int bindid = quarterCore;
//bindProc(bindid);
bindProc(0);
#ifdef USING_MALLOC
head = (List**)malloc(TOTAL_LISTS*sizeof(List*));
allList = (List**)malloc(TOTAL_LISTS*sizeof(List*));
listsLen = (int*)malloc(TOTAL_LISTS*sizeof(int));
listNumber = (int*)malloc(TOTAL_LISTS*sizeof(int));
#else
head = new List*[TOTAL_LISTS];
allList = new List*[TOTAL_LISTS];
listsLen = new int[TOTAL_LISTS];
listNumber = new int[TOTAL_LISTS];
#endif
gettimeofday(&start, NULL);
buildList();
gettimeofday(&end, NULL);
double duration = (end.tv_sec-start.tv_sec) + (end.tv_usec-start.tv_usec)/1000000.0;
std::cerr << "build duration = " << duration << std::endl;
//bindProc(0);
AccirrInit(&argc, &argv);
for (intptr_t i = 0; i < CORO_NUM; i++) {
createTask(tracingTask, (void*)i);
}
gettimeofday(&start, NULL);
AccirrRun();
AccirrFinalize();
gettimeofday(&end, NULL);
duration = (end.tv_sec-start.tv_sec) + (end.tv_usec-start.tv_usec)/1000000.0;
std::cout << "traverse duration " << duration << " s accum " << total_accum << " traverse " << tra_times << std::endl;
std::cerr << "traverse duration " << duration << " s accum " << total_accum << " traverse " << tra_times << std::endl;
destroyList();
return 0;
}
示例14: destroyList
/*7*/void freeData(hashTable arrayHash[])
{
int i;
for(i=0;i<MAX;i++){
if(arrayHash[i].elemStatus == 1){
if(arrayHash[i].collision != NULL){
destroyList(arrayHash[i].collision);
}
free(arrayHash[i].word);
}
}
}//end freeData
示例15: freeValueMemory
void freeValueMemory(void *value)
{
/* check to see if the value was ever set */
if(value == NULL)
{
return;
}
/* else, free the linked list */
else
{
destroyList((linkedList_t *) value);
}
}