当前位置: 首页>>代码示例>>C++>>正文


C++ addToList函数代码示例

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

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

示例1: concatList

listPo concatList(heapPo H, listPo l1, listPo l2) {
  integer len1 = l1->length;
  integer len2 = l2->length;

  if (len1 == 0)
    return l2;
  else if (len2 == 0)
    return l1;
  else {
    int root = gcAddRoot(H, (ptrPo) &l1);
    gcAddRoot(H, (ptrPo) (&l2));

    integer llen = len1 + len2;

    listPo reslt = createList(H, llen + llen / 2);

    for (integer ix = 0; ix < len1; ix++) {
      reslt = addToList(H, reslt, nthEl(l1, ix));
    }
    for (integer ix = 0; ix < len2; ix++) {
      reslt = addToList(H, reslt, nthEl(l2, ix));
    }

    gcReleaseRoot(H, root);
    return reslt;
  }
}
开发者ID:fmccabe,项目名称:cafe,代码行数:27,代码来源:array.c


示例2: addToList

void BST::addToList(std::vector<std::list<Node*> >& nodeLists, Node* node, int level)
{
  //add current node to the list

  // check whether we have the list for level is created.
  std::vector<std::list<Node*> >::iterator it = nodeLists.begin();
  std::list<Node*> list;
  
  for (int i = 0; i < level; i++)  {
    it++;
  }

  if (it == nodeLists.end())
    nodeLists.push_back(list);

  it = nodeLists.begin();

  for (int i = 0; i < level; i++)  {
    it++;
  }
  
  if (it == nodeLists.end()) {
    std::cout << "WTF" <<std::endl;
    return;
  }

  (*it).push_back(node);
  

  if(node->left)
    addToList(nodeLists, node->left, level+1);

  if(node->right)
    addToList(nodeLists, node->right, level+1);
}
开发者ID:stbdang,项目名称:coding_exercise,代码行数:35,代码来源:main.cpp


示例3: getTriplesByPerimeter

void getTriplesByPerimeter(triple * t, const uint64_t limit, triple *** const list, uint32_t * const count, uint32_t * const size) {
  static const int64_t transformationMatrix[3][3][3] =
    {{{ 1,-2, 2}
     ,{ 2,-1, 2}
     ,{ 2,-2, 3}}
    ,{{ 1, 2, 2}
     ,{ 2, 1, 2}
     ,{ 2, 2, 3}}
    ,{{-1, 2, 2}
     ,{-2, 1, 2}
     ,{-2, 2, 3}}};

  uint32_t i;
  uint64_t perimeter_ = perimeter(t);

  if(perimeter_ > limit) {
    free(t);
    return;
  }

  addToList(t,list,count,size);
  for(i=2; i*perimeter_ <= limit; ++i)
    addToList(scalarMultiply(i,t),list,count,size);

  for(i=0; i<3; ++i)
    getTriplesByPerimeter(matrixMultiply((int64_t *)transformationMatrix[i],t)
                         ,limit,list,count,size);
}
开发者ID:recursion-ninja,项目名称:ProjectEuler,代码行数:28,代码来源:s0075.c


示例4: createList

	List *add(List *first, List *second){
		List *result = createList();
		ListElement *currentFirst = first->head->next;
		ListElement *currentSecond = second->head->next;
		while (currentFirst != nullptr || currentSecond != nullptr){

			if (currentFirst == nullptr){
				addToList(currentSecond->power, currentSecond->ratio, result);
				currentSecond = currentSecond->next;
			}
			else if (currentSecond == nullptr){
				addToList(currentFirst->power, currentFirst->ratio, result);
				currentFirst = currentFirst->next;
			}
			else{
				if (currentFirst->power > currentSecond->power){
					addToList(currentFirst->power, currentFirst->ratio, result);
					currentFirst = currentFirst->next;
				}
				else if (currentFirst->power < currentSecond->power){
					addToList(currentSecond->power, currentSecond->ratio, result);
					currentSecond = currentSecond->next;
				}
				else{
					if (currentSecond->ratio + currentFirst->ratio != 0)
						addToList(currentSecond->power, currentSecond->ratio + currentFirst->ratio, result);
					currentSecond = currentSecond->next;
					currentFirst = currentFirst->next;				
				}
			}

		}

		return result;
	}
开发者ID:antongulikov,项目名称:Homework,代码行数:35,代码来源:polynom.cpp


示例5: clearList

	Status LogReader::SetFilter(const char *a_filter, unsigned int a_filterSize,
												unsigned int a_maxFindSize, bool a_raw)
	{
		if (a_filterSize > 0 && a_filter == InvPtr)
			return s_invalidParameter;

		m_filter = a_filter;
		m_filterSize = a_filterSize;
		clearList();
		StrClose *l_strClose;
		if (!a_raw)
		{
			StrEntry *const l_strEntry = new(std::nothrow) StrEntry;
			if (l_strEntry == InvPtr)
				return s_memAllocError;

			l_strClose = new(std::nothrow) StrClose;
			if (l_strClose == InvPtr)
			{
				delete l_strEntry;
				return s_memAllocError;

			}

			addToList(l_strEntry);

		}

		m_status = s_ok;
		machine();
		if (m_status == s_ok && m_list == InvPtr)
		{
			Substit *const l_substit = new(std::nothrow) Substit(0, true);
			if (l_substit == InvPtr)
				m_status = s_memAllocError;
			else
				addToList(l_substit);

		}

		if (m_status != s_ok)
		{
			delete l_strClose;
			clearList();

		}
		else
		{
			if (!a_raw)
				addToList(l_strClose);

			m_raw = a_raw;
			m_maxFindSize = a_maxFindSize;
			reset();

		}

		return m_status;

	}
开发者ID:rasim-valiullin,项目名称:d512388b-9b91-45f9-8f88-b6d4e252c270,代码行数:60,代码来源:logreader.cpp


示例6: createLists

    void createLists()
    {
        int iRnd = getRndNumber(0, 10);
        lnNode = new ListNode(iRnd, NULL);

        ListNode* tmpNode = NULL;

        iRnd = getRndNumber(0, 10);
        tmpNode = new ListNode(iRnd, NULL);
        tmpNode->next = lnNode;
        lnNode = tmpNode;

        iRnd = getRndNumber(0, 10);
        tmpNode = new ListNode(iRnd, NULL);
        tmpNode->next = lnNode;
        lnNode = tmpNode;

        //---------------------------------
        iRnd = getRndNumber(0, 10);
        lnNodePM = new ListNode(iRnd, NULL);

        iRnd = getRndNumber(0, 10);
        addToList(iRnd);
        iRnd = getRndNumber(0, 10);
        addToList(iRnd);

    }
开发者ID:MakSim345,项目名称:cpp,代码行数:27,代码来源:main.cpp


示例7: test_addToList_adds_the_given_data_to_the_list_also_increments_the_length

void test_addToList_adds_the_given_data_to_the_list_also_increments_the_length () {
	LinkedList list = createList();
	int a = 5;
	addToList(&list, &a);
	assert(list.length == 1);
	addToList(&list, &a);
	assert(list.length == 2);
}
开发者ID:SRJPN,项目名称:C_Assignment,代码行数:8,代码来源:linkedListTest.c


示例8: builtin

 Expr builtin(Type t, const std::string &name, Expr a, Expr b) {
     MLVal args = makeList();
     args = addToList(args, b.node());
     args = addToList(args, a.node());
     Expr e(makeExternCall(t.mlval, name, args), t);
     e.child(a);
     e.child(b);
     return e;
 }
开发者ID:FreeAlex,项目名称:Halide,代码行数:9,代码来源:Expr.cpp


示例9: test_getLastElement_gives_the_address_of_last_element_in_the_list

void test_getLastElement_gives_the_address_of_last_element_in_the_list () {
	LinkedList list = createList();
	int a = 5;
	int b = 10;
	addToList(&list, &a);
	addToList(&list, &b);
	Element *element = getLastElement(list);
	assert(*(int *)(element->value) == 10);
}
开发者ID:SRJPN,项目名称:C_Assignment,代码行数:9,代码来源:linkedListTest.c


示例10: iteration

void iteration(struct GOL *gol)
{
	struct Cell *cell;
	unsigned int i;
	unsigned int count;
	unsigned int threadNum;
	double ccTime, wupTime, thTime;

	// TODO: it can be multithread?
	reviveCells(&gol->toRevive[0], gol->world);
	killCells(&gol->toKill[0], gol->world);

	ccTime = startMeasurement();
	#pragma omp parallel shared(gol) private(cell, count, threadNum, thTime)
	{
		thTime = startMeasurement();

		threadNum = omp_get_thread_num();

		for (cell = wit_first_split(&count, threadNum, gol->world);
		     wit_done_split(count, gol->world);
		     cell = wit_next_split(cell, &count, gol->numThreads))
		{
			switch (checkRule(cell, gol->rule)) {
			case GOL_REVIVE:
				addToList(cell, &gol->toRevive[threadNum]);
				break;
			case GOL_KILL:
				addToList(cell, &gol->toKill[threadNum]);
				break;
			case GOL_SURVIVE:
			case GOL_KEEP_DEAD:
			default:
				break;
			}
		}

		endMeasurement(thTime, threads[threadNum], gol->stats);
	}
	endMeasurement(ccTime, cellChecking, gol->stats);

	wupTime = startMeasurement();
	// Add lists
	for (i = 0; i < gol->numThreads; ++i) {
		reviveCells(&gol->toRevive[i], gol->world);
		freeList(&gol->toRevive[i]);
	}

	// Free lists
	for (i = 0; i < gol->numThreads; ++i) {
		killCells(&gol->toKill[i], gol->world);
		freeList(&gol->toKill[i]);
	}
	endMeasurement(wupTime, worldUpdate, gol->stats);
}
开发者ID:FarK,项目名称:GameOfLife,代码行数:55,代码来源:gol.c


示例11: 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);
}
开发者ID:sourekj,项目名称:Packages,代码行数:57,代码来源:rbc.cpp


示例12: main

int main() {
	int data1,data2,data3,data4,data5;
	int nonData = 6;
	int * pFind = NULL;
	List test = NULL;
	initList(&test);

	data1 = 10;data2 = 20;data3 = 30;data4 = 40;data5 = 50;
	addToList(test, (void*)&data1);
	addToList(test, (void*)&data2);
	addToList(test, (void*)&data3);
	addToList(test, (void*)&data4);
	addToList(test, (void*)&data5);
	displayList(test);

	printf("%s","Searching for 30");
	pFind = (int*)findInList(test, (void*)&data3, intGreater);

	if (pFind)
	{
		printf("%s%d","\nFound data value: ", *pFind);
	}
	else {
		printf("%s","\nData not found");
	}

	printf("%s","\nSearching for 99 (shouldn't be in list)");
	pFind = (int*)findInList(test, (void*)&nonData, intGreater);

	if (pFind)
	{
		printf("%s%d","\nFound data value: ", *pFind);
	}
	else {
		printf("%s","\nData not found");
	}

	printf("%s","\nremoving one item then displaying\n");
	removeFirst(test);
	displayList(test);

	printf("%s","removing all items then displaying\n");
	deleteList(test);
	displayList(test);

	printf("%s","Attempting to remove from an empty list\n");
	removeFirst(test);
	displayList(test);

	cleanupList(&test);

	printf("%s","All tests complete\n");

	return 0;
}
开发者ID:Zonr0,项目名称:asmlist,代码行数:55,代码来源:listdriver.c


示例13: test_getElementAt_gives_the_address_of_the_element_at_given_index

void test_getElementAt_gives_the_address_of_the_element_at_given_index () {
	LinkedList list = createList();
	int a = 5;
	int b = 10;
	void *element;
	addToList(&list, &a);
	addToList(&list, &b);

	element = getElementAt(list, 1);

	assert(*(int *)element == 10);
}
开发者ID:SRJPN,项目名称:C_Assignment,代码行数:12,代码来源:linkedListTest.c


示例14: test_getElementAt_gives_the_NULL_for_a_given_invalid_index

void test_getElementAt_gives_the_NULL_for_a_given_invalid_index () {
	LinkedList list = createList();
	int a = 5;
	int b = 10;
	void *element;
	addToList(&list, &a);
	addToList(&list, &b);

	element = getElementAt(list, 9);

	assert(element == NULL);
}
开发者ID:SRJPN,项目名称:C_Assignment,代码行数:12,代码来源:linkedListTest.c


示例15: test_indexOf_returns_the_index_of_given_address_of_the_value

void test_indexOf_returns_the_index_of_given_address_of_the_value () {
	LinkedList list = createList();
	int a = 5;
	int b = 10;
	void *element;
	addToList(&list, &a);
	addToList(&list, &b);

	int index = indexOf(list, &b);

	assert(index == 1);
}
开发者ID:SRJPN,项目名称:C_Assignment,代码行数:12,代码来源:linkedListTest.c


示例16: primeFactorization

char* primeFactorization(long int num, int* success) {
	// Make sure success poniter is valid
	if (success == NULL) {
		return NULL;
	} else {
		*success = '\0';
	}

	// Make sure we have a number greater than 1
	if (num <= 1) {
		*success = -1;
		return NULL;
	}

	// Allocate space for the list and initialize it
	char* list = (char*)malloc(sizeof(char));
	list[0] = '\0';

	// Check if input is already prime.
	// If so, return the input num.
	if (isPrime(num) == 1) {
		*success = 1;
		list = addToList(list, num, 1);
		return list;
	}

	// Set starting base and power variables
	long int base = 2;
	long int power = 0;

	while (num != 1) {
		while (num % base == 0) {
			num /= base;
			power++;
		}

		if (power != 0) {
			list = addToList(list, base, power);

			// Check if the new num is prime.
			// If so, add it to the list and break.
			if (num != 1 && isPrime(num) == 1) {
				list = addToList(list, num, 1);
				break;
			}
			power = 0;
		}
		base = getNextPrime(base);
	}
	*success = 1;
	return list;
}
开发者ID:DigitalStuffMan,项目名称:Math-Functions,代码行数:52,代码来源:PrimeFactorization.c


示例17: test_indexOf_returns_the_minus_one_of_given_address_of_the_value_if_the_value_is_not_found

void test_indexOf_returns_the_minus_one_of_given_address_of_the_value_if_the_value_is_not_found () {
	LinkedList list = createList();
	int a = 5;
	int b = 10;
	int c = 15;
	void *element;
	addToList(&list, &a);
	addToList(&list, &b);

	int index = indexOf(list, &c);

	assert(index == -1);
}
开发者ID:SRJPN,项目名称:C_Assignment,代码行数:13,代码来源:linkedListTest.c


示例18: main

int main(int argc, const char *argv[])
{
        int i;
        int soma = 0;
        int tamanho = argc - 1;

        List list;
        initializeList(&list);

        for (i = 1; i < argc; i++)
        {
                list.head = addToList(&list, atoi(argv[i]), true);
                soma += atoi(argv[i]);
        }
        
        printf("Conjunto: ");
        print(&list);

        if (soma%2 == 0)
        {
                int metade = soma / 2;
                if (max(&list) <= metade)
                {
                        List partition1;
                        initializeList(&partition1);
                        int val = getVal(&list, 0);
                        partition1.head = addToList(&partition1,  val, true);
                        List partition2;
                        partition2 = copy(&list);
                        del(&partition2, val);
                        algoritmo(0 + val, metade, tamanho, &partition1, &partition2, &list, 1);
                        destroy(&list);
                        destroy(&partition1);
                        destroy(&partition2);
                        printf("Quantidade de resultados: %d\n", qtdResult);
                }
                else
                {
                        printf("Não foi encontrado\n");
                        destroy(&list);
                }

        }
        else
        {
                printf("Não foi encontrado\n");
                destroy(&list);
        }
        return 0;
}
开发者ID:execb5,项目名称:Random-Codes,代码行数:50,代码来源:t3.c


示例19: new

	void LogReader::sample2Function()
	{
		if (m_list == InvPtr || !m_raw && m_list->m_next == InvPtr)
		{
			Substit *const l_substit = new(std::nothrow) Substit(0, true);
			if (l_substit == InvPtr)
			{
				m_status = s_memAllocError;
				return;

			}

			addToList(l_substit);

		}

		const unsigned int l_sourceDataSize = m_i - m_elementEntry - m_escapes;
		char *const l_sourceData = new(std::nothrow) char[l_sourceDataSize];
		if (l_sourceData == InvPtr)
		{
			m_status = s_memAllocError;
			return;

		}

		unsigned int j = 0;
		bool l_escape = false;
		for (unsigned int i = m_elementEntry; i < m_i; i++)
		{
			const char l_nextOne = m_filter[i];
			l_escape = !l_escape && l_nextOne == s_escape;
			if (l_escape)
				continue;

			l_sourceData[j] = l_nextOne;
			j++;

		}

		Sample *const l_sample = new(std::nothrow) Sample(l_sourceData, l_sourceDataSize);
		if (l_sample != InvPtr)
			addToList(l_sample);
		else
		{
			delete[] l_sourceData;
			m_status = s_memAllocError;

		}

	}
开发者ID:rasim-valiullin,项目名称:d512388b-9b91-45f9-8f88-b6d4e252c270,代码行数:50,代码来源:logreader.cpp


示例20: addToList

void kicad_module_scanner::closeEvent(QCloseEvent *event)
{
	settings->clear(); //must clear everything first otherwise items deleted in say a cbo box won't get removed

	//save General Setup tab
	settings->setValue("leShellWorkerScript", ui.leShellWorkerScript->text());
	settings->setValue("leAwkScript", ui.leAwkScript->text());
	settings->setValue("leCopierScript", ui.leCopierScript->text());
	settings->setValue("leExtractorScript", ui.leExtractorScript->text());
	addToList(ui.cboPostscriptViewer); //save any user amendments - they don't get saved anywhere else
	saveCboSettings(ui.cboPostscriptViewer);
	addToList(ui.cboViewerTemporaryFile); //save any user amendments - they don't get saved anywhere else
	saveCboSettings(ui.cboViewerTemporaryFile);

	//save Folder Scanning tab
	saveLstSettings(ui.lstFoldersToScan);
	saveRdoSettings(ui.rdoFolderScanOutputOverwrite);
	saveRdoSettings(ui.rdoFolderScanOutputAppend);
	saveChkSettings(ui.chkFolderIncludePostscript);
	addToList(ui.cboOutputFile_FolderScanning);
	saveCboSettings(ui.cboOutputFile_FolderScanning);

	//save File Scanning tab
	saveLstSettings(ui.lstFilesToScan);
	saveRdoSettings(ui.rdoFileScanOutputOverwrite);
	saveRdoSettings(ui.rdoFileScanOutputAppend);
	saveChkSettings(ui.chkFileIncludePostscript);
	addToList(ui.cboOutputFile_FileScanning);
	saveCboSettings(ui.cboOutputFile_FileScanning);

	//save Finding/Copying tab
	saveCboSettings(ui.cboDatabaseFile);
	settings->setValue("spinBoxNumPins", ui.spinBoxNumPins->value());
	addToList(ui.cboFootprintName);
	saveCboSettings(ui.cboFootprintName);
	addToList(ui.cboKeywords);
	saveCboSettings(ui.cboKeywords);
	addToList(ui.cboDescription);
	saveCboSettings(ui.cboDescription);
	saveChkSettings(ui.chkPins);
	saveCboSettings(ui.cboFootprintName);
	saveChkSettings(ui.chkFootprintName);
	saveChkSettings(ui.chkKeywords);
	saveChkSettings(ui.chkDescription);
	saveChkSettings(ui.chkAutoPreview);
//	saveChkSettings(ui.chkShowPinNumbers);
//	settings->setValue(ui.cboScale->objectName(), ui.cboScale->currentIndex());//item list is fixed, do not use saveCbo
	settings->setValue(ui.leCopyToModule->objectName(), ui.leCopyToModule->text());
	addToList(ui.cboCopyToLibrary); //save any user amendments - they don't get saved anywhere else
	saveCboSettings(ui.cboCopyToLibrary);
	saveChkSettings(ui.chkAllowOverwrite);
	saveBtnSettings(ui.btnViewingMode);
	saveBtnSettings(ui.btnCopyingMode);
	settings->sync(); //do not remove
//	if (this->viewerIsRunning == true) {
//		this->viewerProcess->close();
//	}
	event->accept();
}
开发者ID:JayNaire,项目名称:kicad-module-scanner-old,代码行数:59,代码来源:kicad_module_scanner.cpp



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