// searches IDList idL for std::string s, returns its position, -1 if not found inline int FindInIDList(IDList& idL,const std::string& s) { // int ix=0; for(IDList::iterator i=idL.begin(); i != idL.end(); ++i)//, ++ix) if( *i==s) { return i - idL.begin(); } return -1; }
//------------------------------------------------------------------------------ void Solver::HashTable::Fill ( const IDList& particleIDs ) { // clear all buckets for (unsigned int i = 0; i < mDomain.Dimensions.X*mDomain.Dimensions.Y; i++) { mBuckets[i].clear(); } // fill buckets IDList::const_iterator i = particleIDs.begin(); IDList::const_iterator e = particleIDs.end(); for (; i != e; i++) { unsigned int hash = computeHash ( Vector2f(&mPositions[2*(*i)]), mDomain ); mBuckets[hash].push_back(*i); } }
int Find( const std::string& name) { String_abbref_eq strAbbrefEq_name(name); // search keyword IDList::iterator f=std::find_if(listName.begin(), listName.end(), strAbbrefEq_name); if( f == listName.end()) return -1; // Note: there might be duplicate extra keyword names, return first one // // continue search (for ambiguity) // IDList::iterator ff=std::find_if(f+1, // listName.end(), // strAbbrefEq_name); // if( ff != listName.end()) // { // throw GDLException("Ambiguous keyword abbreviation in _EXTRA: "+name); // } return std::distance( listName.begin(),f); }
void BaseSemanticWalker::declare(const IDList& ids, Type* type) { IDList::const_iterator it; for (it = ids.begin(); it != ids.end(); ++it) { try { _symtable->insertSymbol( Symbol((*it)->getText(), type, _symtable->currentScope(), _symtable->unit(), (*it)->getLine(), (*it)->getColumn())); } catch (RedeclarationException e) { report((*it)->getLine(), (*it)->getColumn(), std::string("redeclaraĆ§Ć£o: ") + e.symbol().lexeme()); } } }
int printClusters(NodeSet roots, IDList orphanNodes, string clusterListName, string clusterName, vector<float> cutoffs) { TreeNode *tempNode = 0; NodeSetIter setIter; NodeList nodeList, tempList; NodeListIter nodeIt, tempIt; IDList OTU; IDListIter it; unsigned int size, numOTUs; FILE *clusterListFile, *clusterFile; clusterListFile = fopen(clusterListName.c_str(),"wb"); clusterFile = fopen(clusterName.c_str(),"wb"); if(clusterListFile == NULL|| clusterFile == NULL) { cout << "Cannot open output files. Skipped" << endl; return 0; } printf("\n"); vector<float>::iterator c; float distLevel; for(c = cutoffs.begin(); c != cutoffs.end(); c++) { distLevel = *(c); numOTUs = 0; nodeList.clear(); // extract the valid nodes for each distance level for(setIter=roots.begin(); setIter!=roots.end(); ++setIter) { tempNode=0; if(*setIter != 0) { if((*setIter)->dist < distLevel || fabs((*setIter)->dist-distLevel) < EPSILON) { nodeList.push_front(*setIter); continue; } tempList.push_front(*setIter); while (tempList.size()!=0) { tempIt=tempList.begin(); tempNode=(*tempIt); tempList.pop_front(); if (tempNode->left->dist < distLevel || fabs(tempNode->left->dist-distLevel) < EPSILON) nodeList.push_front(tempNode->left); else tempList.push_front(tempNode->left); if (tempNode->right->dist < distLevel || fabs(tempNode->right->dist-distLevel) < EPSILON) nodeList.push_front(tempNode->right); else tempList.push_front(tempNode->right); } } tempList.clear(); } fprintf(clusterListFile," %.6f ", distLevel); fprintf(clusterFile," %.6f ", distLevel); // write the nodeList to file tempList.clear(); for(nodeIt=nodeList.begin(); nodeIt!=nodeList.end(); ++nodeIt) { // clean up and initialize fprintf(clusterFile,"|"); tempNode=0; size=0; OTU.clear(); tempList.push_front(*nodeIt); while(tempList.size()!=0) { tempIt=tempList.begin(); tempNode=(*tempIt); tempList.pop_front(); if(tempNode->left==0 && tempNode->right==0) { OTU.push_back(tempNode->ID); size+=tempNode->numMembers; } if (tempNode->right!=0) tempList.push_front(tempNode->right); if(tempNode->left!=0 ) tempList.push_front(tempNode->left); } tempList.clear(); // print to clusterFile it=OTU.begin(); fprintf(clusterFile,"%u",(*it)); ++it; for(;it!=OTU.end(); ++it) fprintf(clusterFile," %u",(*it)); fprintf(clusterListFile, "%d ", size); ++numOTUs; } for (it=orphanNodes.begin(); it != orphanNodes.end(); ++it) { fprintf(clusterFile,"|%u",(*it)); fprintf(clusterListFile, "1 "); } numOTUs += orphanNodes.size(); fprintf(clusterFile,"|\n"); fprintf(clusterListFile, "\n"); printf("Dist: %.6f. numOTUs: %u. numSingletons: %lu\n", distLevel, numOTUs, orphanNodes.size()); } printf("\n"); OTU.clear(); fclose(clusterListFile); fclose(clusterFile); return 1; }
void UpdateData::addGUID(const IDList& id) { m_guidList.insert(id.begin(), id.end()); }