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


C++ set::find方法代码示例

本文整理汇总了C++中set::find方法的典型用法代码示例。如果您正苦于以下问题:C++ set::find方法的具体用法?C++ set::find怎么用?C++ set::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在set的用法示例。


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

示例1: sizeof

int wpl_text_chunks::text::output_json (
		wpl_text_state *state,
		const set<wpl_value*> &vars,
		wpl_text_chunk_it *it,
		wpl_value *final_result
) {
	const char id_string[] = "id=\"";
	const int id_string_len = sizeof(id_string)-1;

	wpl_io &io = state->get_io();
	wpl_io_void io_void;
	wpl_value_string json_name;
	wpl_value_string json_value;
	wpl_value_unsafe_pointer unsafe_pointer;

	json_name.set_do_finalize();
	json_value.set_do_finalize();
	unsafe_pointer.set_do_finalize();

	/*
	   If we end with an HTML id tag, use this the text value of the
	   next chunk as the JSON name.
	   */
	if (strncmp (end - id_string_len, id_string, id_string_len) != 0) {
		return (*(++(*it)))->output_json(state, vars, it, final_result);
	}

	/*
	   If no return from the next block, just proceed with output_json
	   */
	if (!((*(++(*it)))->run(state, it->get_pos(), &json_name, io_void) & WPL_OP_OK)) {
		return (*it)->output_json(state, vars, it, final_result);
	}

	/*
	   The next block which returns WPL_OP_OK is the expression
	   whos pointer is used to match against the list of requested
	   variables to output.

	 */
	while (true) {
	   	// it++ throws wpl_text_chunk_end_reached() when we're done
		(*it)++;

		/*
		   Check if the next chuck is an expression with return value
		   */
		if (!((*it)->run(state, it->get_pos(), &unsafe_pointer, io_void) & WPL_OP_OK)) {
			continue;
		}

		/*
		   Check if the value exists in the list
		   */
		if (vars.find(unsafe_pointer.dereference()) == vars.end()) {
			continue;
		}

		/*
		   All OK, output this variable
		   */
		(*it)->run(state, it->get_pos(), &json_value, io_void);
		io << "\"";
		json_name.output_json(io);
		io << "\": \"";
		json_value.output_json(io);
		io << "\",\n";

		(*it)++;

		return (*it)->output_json(state, vars, it, final_result);
	}

	return WPL_OP_NO_RETURN;
}
开发者ID:tariqzafar007,项目名称:P-star-1,代码行数:75,代码来源:text.cpp

示例2: computeOptimalStiffnessMatrix


//.........这里部分代码省略.........
            bilinearForm->applyBilinearFormData(materialDataAppliedToTrialValues,materialDataAppliedToTestValues, 
                                               trialID,testID,operatorIndex,physicalCubaturePoints);
              
            int testDofOffset = testOrdering->getDofIndex(testID,0);
            // note that weightCellBasisValues does depend on contiguous test basis dofs...
            // (this is the plan, since there shouldn't be any kind of identification between different test dofs,
            //  especially since test functions live only inside the cell)
            weightCellBasisValues(materialDataAppliedToTestValues, weights, testDofOffset);
              
            FunctionSpaceTools::integrate<double>(miniStiffness,materialDataAppliedToTestValues,materialDataAppliedToTrialValues,COMP_BLAS);
            // place in the appropriate spot in the element-stiffness matrix
            // copy goes from (cell,trial_basis_dof,test_basis_dof) to (cell,element_trial_dof,element_test_dof)
            
            // there may be a more efficient way to do this copying:
            // (one strategy would be to reimplement fst::integrate to support offsets, so that no copying needs to be done...)
            for (int i=0; i < testBasis->getCardinality(); i++) {
              for (int j=0; j < trialBasis->getCardinality(); j++) {
                int trialDofIndex = trialOrdering->getDofIndex(trialID,j);
                for (unsigned k=0; k < numCells; k++) {
                  stiffness(k,optTestIndex,trialDofIndex) += miniStiffness(k,i,j);
                }
              }
            }          
          } else {  // boundary integral
            int trialBasisRank = trialOrdering->getBasisRank(trialID);
            int testBasisRank = testOrdering->getBasisRank(testID);
            
            TEUCHOS_TEST_FOR_EXCEPTION( ( trialBasisRank != 0 ),
                               std::invalid_argument,
                               "Boundary trial variable (flux or trace) given with non-scalar basis.  Unsupported.");
            
            bool isFlux = false; // i.e. the normal is "folded into" the variable definition, so that we must take parity into account
            const set<int> normalOperators = BilinearForm::normalOperators();
            if (   (normalOperators.find(testOperator)  == normalOperators.end() ) 
                && (normalOperators.find(trialOperator) == normalOperators.end() ) ) {
              // normal not yet taken into account -- so it must be "hidden" in the trial variable
              isFlux = true;
            }
            
            for (unsigned sideOrdinal=0; sideOrdinal<numSides; sideOrdinal++) {
              trialBasis = trialOrdering->getBasis(trialID,sideOrdinal);
              testBasis = testOrdering->getBasis(testID);
              
              FieldContainer<double> miniStiffness( numCells, testBasis->getCardinality(), trialBasis->getCardinality() );
              
              // for trial: we never dot with normal, and the value lives on the side, so we don't use the volume coords either:
              trialValuesTransformed = basisCache.getTransformedValues(trialBasis,trialOperator,sideOrdinal,false);
              // for test: first, don't dot with normal, but do use the volume coords:
              //testValuesTransformed = basisCache.getTransformedValues(testBasis,testOperator,sideOrdinal,true);
              testValuesTransformedWeighted = basisCache.getTransformedWeightedValues(testBasis,testOperator,sideOrdinal,true);
              
              // copy before manipulating trialValues--these are the ones stored in the cache, so we're not allowed to change them!!
              FieldContainer<double> materialDataAppliedToTrialValues = *trialValuesTransformed;
              if (isFlux) {
                // this being a flux ==> take cell parity into account (because then there must be a normal folded into the flux definition)
                // we need to multiply the trialValues by the parity of the normal, since
                // the trial implicitly contains an outward normal, and we need to adjust for the fact
                // that the neighboring cells have opposite normal
                // trialValues should have dimensions (numCells,numFields,numCubPointsSide)
                int numFields = trialValuesTransformed->dimension(1);
                int numPoints = trialValuesTransformed->dimension(2);
                for (unsigned cellIndex=0; cellIndex<numCells; cellIndex++) {
                  double parity = cellSideParities(cellIndex,sideOrdinal);
                  if (parity != 1.0) {  // otherwise, we can just leave things be...
                    for (int fieldIndex=0; fieldIndex<numFields; fieldIndex++) {
                      for (int ptIndex=0; ptIndex<numPoints; ptIndex++) {
开发者ID:Kun-Qu,项目名称:Camellia,代码行数:67,代码来源:BilinearFormUtility.cpp

示例3: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	long pmax = 10000000;
	vector<long> primes = sieve_of_eratosthenes(pmax);

	long long sum = 0;

	for (vector<long>::iterator it=primes.begin(); it!= primes.end(); it++)
	{
		long p = *it;

		// every 1 digit prime is a relative
		if (p<10) {
			relatives.insert(*it);
			continue;
		}

		bool condition_met = false;

		// condition 1
		// change all digits possible
		int len = findn(*it);
		for (long exponent=1; exponent < p ; exponent *= 10) {
			long limit = p/exponent % 10;
			long newp = p;
			for (int n=0; n<limit; n++) {
				newp -= exponent;
				if (relatives.find(newp) != relatives.end() && findn(newp) + 1 >= len) {
					relatives.insert(*it);
					exponent=p;
					n=limit;
					condition_met=true;
				}
			}
		}

		// condition 2
		// remove leftmost digit
		if ( condition_met == false ) {
			long newp = p % getexp(p);
			if (relatives.find(newp) != relatives.end() && findn(newp) + 1 >= len) {
				relatives.insert(*it);
				condition_met=true;
			}
		}

		if (condition_met) {
			if ( no_relatives.size() > 0 ) {
				set<long> erased = recheck_non_relatives(p);
				set<long> erased2;
				set<long> new_erased;

				while (erased.size() > 0) {
					erased2.clear();
					new_erased.clear();
					for (set<long>::iterator sit=erased.begin(); sit != erased.end(); sit++) {
						erased2 = recheck_non_relatives(*sit);
						for (set<long>::iterator sit2=erased2.begin(); sit2 != erased2.end(); sit2++) {
							new_erased.insert(*sit2);
						}
					}
					erased = new_erased;
				}
			}
		}
		else {
			no_relatives.insert(*it);
			sum += *it;
			cout << *it << endl;
		}
	}

	
	cout << "--------------" << endl << sum << endl;

	system("PAUSE");
	return 0;
}
开发者ID:edlerd,项目名称:projectEulerCpp,代码行数:78,代码来源:peuler425.cpp

示例4: contains

bool contains(set<T> container, string key) {
	return container.find(key) != container.end();
}
开发者ID:CloudMetal,项目名称:AppleGuice,代码行数:3,代码来源:appleGuiceBootstrapper.cpp

示例5: handle

 virtual void handle() {
     // the host has departed
     //
     set<HOST*>::iterator i = hosts.find(this);
     hosts.erase(i);
 }
开发者ID:keyz182,项目名称:BOINC-7.0,代码行数:6,代码来源:ssim.cpp

示例6: addUrlIfNotContain

		void addUrlIfNotContain(string url) {
			boost::mutex::scoped_lock mylock(urlsMutex);
			if ((parsedPages.find(url) == parsedPages.end()) && (pagesToParse.find(url) == pagesToParse.end())) {
				pagesToParse.insert(url);
			}
		}
开发者ID:unpxre,项目名称:big-data,代码行数:6,代码来源:big-data.cpp

示例7: IsSpiceKernelLoaded

/*! Return true if a SPICE kernel has already been loaded, false if not.
 */
bool IsSpiceKernelLoaded(const string& filepath)
{
	return ResidentSpiceKernels.find(filepath) != ResidentSpiceKernels.end();
}
开发者ID:Habatchii,项目名称:celestia,代码行数:6,代码来源:spiceinterface.cpp

示例8: dfs

void dfs(string str, int deep)
{
	if (flag)
		return;
	if (str.size() == 47)
	{
		if (str == original)
		{
			flag = 1;
			times = deep;
		}
		return;
	}
	int i, j;
	for (i = 0; i < str.size(); ++i)
	{
		if (str[i] == 'C' || str[i] == 'O' || str[i] == 'W')
			break;
	}
	if (!prefix(str, i))
		return;
	if (str[i] != 'C')
		return;
	int pre = i + 1, start = i;
	bool cut = 0;
	for (i = pre; i < str.size(); ++i)
	{
		if (str[i] == 'C' || str[i] == 'O' || str[i] == 'W')
		{
			if (!sub(str, pre, i))
			{
				cut = 1;
				break;
			}
			pre = i + 1;
		}
	}
	if (cut)
		return;
	if (str[pre - 1] != 'W')
		return;
	if (!suffix(str, pre))
		return;
	for (j = 0; j < str.size(); ++j)
	{
		if (flag)
			return;
		for (i = 0; i < j; ++i)
		{
			if (flag)
				return;
			for (int k = str.size() - 1; k > j; --k)
			{
				if (flag)
					return;
				if (str[i] == 'C' && str[j] == 'O' && str[k] == 'W')
				{
					string temp;
					for (int l = 0; l < i; ++l)
						temp += str[l];
					for (int l = j + 1; l < k; ++l)
						temp += str[l];
					for (int l = i + 1; l < j; ++l)
						temp += str[l];
					for (int l = k + 1; l < str.size(); ++l)
						temp += str[l];
					if (st.find(temp) == st.end() && st.size() < 50000)   //Ì«¼ÙÁË- -
					{
						st.insert(temp);
						dfs(temp, deep + 1);
					}
				}
			}
		}
	}
}
开发者ID:maliemin-Mstar,项目名称:USACO_TRAINING,代码行数:76,代码来源:Cryptcowgraphy.cpp

示例9: add_include_names

void add_include_names( const string& file_name, bool is_root_file = true )
{
   string path;

   ifstream inpf( file_name.c_str( ) );

   if( is_root_file && !inpf )
   {
      cerr << "Error: Unable to open source file '" << file_name << "' for input." << endl;
      exit( 1 );
   }

   if( !is_root_file )
   {
      set< string >::iterator i;
      for( i = include_paths.begin( ); i != include_paths.end( ); ++i )
      {
         string str( *i );
         str += '\\';
         str += file_name;

         inpf.clear( );
         inpf.open( str.c_str( ), ios::in );
         if( inpf )
         {
            path = *i;
            break;
         }
      }

      if( !inpf )
      {
         cerr << "Error: Unable to open source file '" << file_name << "' for input." << endl;
         exit( 1 );
      }

      string str( path );
      if( !str.empty( ) )
         str += '\\';

      str += file_name;
      transform_path_separators( str );

      if( include_names.find( str ) != include_names.end( ) )
         return;

      include_names.insert( str );
      size_t pos = str.find_last_of( '\\' );
      if( pos != string::npos )
      {
         string current = str.substr( 0, pos );
         if( include_paths.find( current ) == include_paths.end( ) )
            include_paths.insert( current );
      }
   }

   string line, include;
   while( getline( inpf, line ) )
   {
      if( get_include_name( line, include ) )
         add_include_names( include, false );
   }
}
开发者ID:rhelwig,项目名称:ciyam,代码行数:63,代码来源:gendeps.cpp

示例10: main

int main( ) {

    freopen( "ttwo.in", "r", stdin );
    freopen( "ttwo.out", "w", stdout );

    for ( int i = 1; i < MAXN; ++i ) {
        for ( int j = 1; j < MAXN; ++j ) {
            scanf( " %c", &maze[i][j] );
        }
    }
    
    for ( int i = 0; i <= MAXN; ++i ) {
        maze[0][i] = '*';
        maze[MAXN][i] = '*';
        maze[i][0] = '*';
        maze[i][MAXN] = '*';
    }

    state start;
    
    for ( int i = 1; i <= MAXN; ++i )
        for ( int j = 1; j <= MAXN; ++j ) {
            if ( maze[i][j] == 'F' ) {
                start.john_x = i;
                start.john_y = j;
                start.john_dir = NORTH;
                maze[i][j] = '.';
            }else if ( maze[i][j] == 'C' ) {
                start.cow_x = i;
                start.cow_y = j;
                start.cow_dir = NORTH;
                maze[i][j] = '.';
            }
        }
        
    start.cost = 0;
    
    q.push( start );
    s.insert( vstate( start ) );
    
    if ( check( start ) ) {
        printf( "0\n" );
        return 0;
    }
    
    while ( !q.empty() ) {
        
        state top = q.front();
        q.pop();
        
        ++top.cost;
       
        state tmp = top;
       
        if ( valid( top.cow_x + dx[ top.cow_dir ], top.cow_y + dy[ top.cow_dir ] ) ) {
                
            if ( maze[ top.cow_x + dx[ top.cow_dir ] ][ top.cow_y + dy[ top.cow_dir ] ] == '*' ) {
                tmp.cow_dir += 1;
                tmp.cow_dir %= MODN;
            }else {
                tmp.cow_x += dx[ tmp.cow_dir ];
                tmp.cow_y += dy[ tmp.cow_dir ];
            }
                
        }else {
            tmp.cow_dir += 1;
            tmp.cow_dir %= MODN;
        }
        
        if ( valid( top.john_x + dx[ top.john_dir ], top.john_y + dy[ top.john_dir ] ) ) {
            
            if ( maze[ top.john_x + dx[ top.john_dir ] ][ top.john_y + dy[ top.john_dir ] ] == '*' ) {
                tmp.john_dir += 1;
                tmp.john_dir %= MODN;
            }else {
                tmp.john_x += dx[ tmp.john_dir ];
                tmp.john_y += dy[ tmp.john_dir ];
            }

        }else {
            tmp.john_dir += 1;
            tmp.john_dir %= MODN;
        }
        
        if ( s.find( vstate( tmp ) ) == s.end( ) ) {
        
            q.push( tmp );
            s.insert( vstate( tmp ) );
            
            if ( check( tmp ) ) {
                printf( "%d\n", tmp.cost );
                found = true;
                break;
            }
            
        }
        
    }
    
    if ( !found ) {
//.........这里部分代码省略.........
开发者ID:sotirisnik,项目名称:usaco,代码行数:101,代码来源:ttwo.cpp

示例11: mapRecursiveDown

// Map the input segments down until reaching the target genome. If the
// target genome is above the source genome, fail miserably.
// Destructive to any data in the input or results list.
static hal_size_t mapRecursiveDown(list<MappedSegmentPtr> &input, list<MappedSegmentPtr> &results, const Genome *tgtGenome,
                                   const set<string> &namesOnPath, bool doDupes, hal_size_t minLength) {
    list<MappedSegmentPtr> *inputPtr = &input;
    list<MappedSegmentPtr> *outputPtr = &results;

    if (inputPtr->empty()) {
        results = *inputPtr;
        return 0;
    }

    const Genome *curGenome = (*inputPtr->begin())->getGenome();
    assert(curGenome != NULL);
    if (curGenome == tgtGenome) {
        results = *inputPtr;
        return 0;
    }

    // Find the correct child to move down into.
    const Genome *nextGenome = NULL;
    hal_size_t nextChildIndex = numeric_limits<hal_size_t>::max();
    const Alignment *alignment = curGenome->getAlignment();
    vector<string> childNames = alignment->getChildNames(curGenome->getName());
    for (hal_size_t child = 0; nextGenome == NULL && child < childNames.size(); ++child) {
        if (childNames[child] == tgtGenome->getName() || namesOnPath.find(childNames[child]) != namesOnPath.end()) {
            const Genome *childGenome = curGenome->getChild(child);
            nextGenome = childGenome;
            nextChildIndex = child;
        }
    }

    if (nextGenome == NULL) {
        throw hal_exception("Could not find correct child that leads from " + curGenome->getName() + " to " +
                            tgtGenome->getName());
    }

    assert(nextGenome->getParent() == curGenome);

    // Map the actual segments down.
    list<MappedSegmentPtr>::iterator i = inputPtr->begin();
    for (; i != inputPtr->end(); ++i) {
        assert((*i)->getGenome() == curGenome);
        mapDown(*i, nextChildIndex, *outputPtr, minLength);
    }

    // Find paralogs.
    if (doDupes == true) {
        swap(inputPtr, outputPtr);
        outputPtr->clear();
        list<MappedSegmentPtr>::iterator i = inputPtr->begin();
        for (; i != inputPtr->end(); ++i) {
            assert((*i)->getGenome() == nextGenome);
            mapSelf(*i, *outputPtr, minLength);
        }
    }

    if (nextGenome != tgtGenome) {
        // Continue the recursion.
        swap(inputPtr, outputPtr);
        outputPtr->clear();
        mapRecursiveDown(*inputPtr, *outputPtr, tgtGenome, namesOnPath, doDupes, minLength);
    }

    if (outputPtr != &results) {
        results = *outputPtr;
    }

    results.sort(MappedSegment::LessSourcePtr());
    results.unique(MappedSegment::EqualToPtr());
    return results.size();
}
开发者ID:glennhickey,项目名称:hal,代码行数:73,代码来源:halSegmentMapper.cpp

示例12: getSum

	long long getSum(int n, int q, int A, int B, int C){
		ll a = A, b = B, c = C;
		::n = n;
		have.clear();
		for(int i = 0; i < n; i++) {
			a = (a * b + c) % mod;
			ll p = a % (mod - n + i + 1);
			if(have.find(p) != have.end())
				p = mod - n + i;
			have.insert(p);
			arr[i] = mpr(p, i);
		}
		for(int i = 0; i < q; i++) {
			a = (a * b + c) % mod;
			que[i].first = a % n;
			a = (a * b + c) % mod;
			que[i].second = a;
		}
		sort(arr, arr + n);
		nl = 0, nr = 0;
		for(int i = 0; i < n; i++) {
			if(arr[i].first % 2 == 0)
				r[nr++] = arr[i];
			else
				l[nl++] = arr[i];
			loc[arr[i].second] = i;
		}

		ll ans = 0;
		for(int i = 0; i < q; i++) {
			int rloc = loc[que[i].first];
			int pl = 0, pr = nl - 1;
			while(pl != pr) {
				int mid = (pl + pr) / 2;
				int rl = 0, rr = nr;
				while(rl < rr) {
					int rmid = (rl + rr) / 2;
					if(l[mid].first - que[i].second * 2 > r[rmid].first)
						rl = rmid + 1;
					else rr = rmid;
				}
				if(mid + rl >= rloc)
					pr = mid;
				else pl = mid + 1;
			}
			int pans = pl;
			int rl = 0, rr = nr;
			while(rl < rr) {
				int rmid = (rl + rr) / 2;
				if(l[pl].first - que[i].second * 2 > r[rmid].first)
					rl = rmid + 1;
				else rr = rmid;
			}
			pans += rl;
			if(pans == rloc) {
				ans += abs(l[pl].first - que[i].second);
				continue;
			}
			pl = 0, pr = nr - 1;
			while(pl != pr) {
				int mid = (pl + pr) / 2;
				int rl = 0, rr = nl;
				while(rl < rr) {
					int rmid = (rl + rr) / 2;
					if(r[mid].first + que[i].second * 2 > l[rmid].first)
						rl = rmid + 1;
					else rr = rmid;
				}
				pans = mid + rl;
				if(mid + rl >= rloc)
					pr = mid;
				else pl = mid + 1;
			}
			ans += abs(r[pl].first + que[i].second);
			//
			#ifdef DEBUG //......................................................................................................
			pans = pl;
			rl = 0, rr = nl;
			while(rl < rr) {
				int rmid = (rl + rr) / 2;
				if(r[pl].first + que[i].second * 2 > l[rmid].first)
					rl = rmid + 1;
				else rr = rmid;
			}
			pans += rl;
			if(pans != rloc) {
				cerr << 1 << endl;
			}
			#endif //...........................................................................................................

		}

		return ans;
	}
开发者ID:BSBandme,项目名称:online-programming-challenge,代码行数:94,代码来源:500.CPP

示例13: IpDoesPush

bool IpDoesPush (ADDRINT ip)
{
  return (pushIps.find(ip) != pushIps.end());
}
开发者ID:andrewjinyounglee,项目名称:PerVERT,代码行数:4,代码来源:pervert.cpp

示例14: scheduleTasks

void CSSHScheduler::scheduleTasks(const CTopoCore& _topology,
                                  const weakChannelInfoVector_t& _channels,
                                  hostToChannelMap_t& _hostToChannelMap,
                                  set<uint64_t>& _scheduledTasks,
                                  const set<uint64_t>& _tasksInCollections,
                                  bool useRequirement,
                                  const CTopoCore::IdSet_t* _addedTasks)
{
    STopoRuntimeTask::FilterIteratorPair_t tasks = _topology.getRuntimeTaskIterator();
    for (auto it = tasks.first; it != tasks.second; it++)
    {
        uint64_t id = it->first;

        // Check if tasks is in the added tasks
        if (_addedTasks != nullptr && _addedTasks->find(it->first) == _addedTasks->end())
            continue;

        // Check if task has to be scheduled in the collection
        if (_tasksInCollections.find(id) != _tasksInCollections.end())
            continue;

        // Check if task was already scheduled in the collection
        if (_scheduledTasks.find(id) != _scheduledTasks.end())
            continue;

        CTopoTask::Ptr_t task = it->second.m_task;

        // First path only for tasks with requirements;
        // Second path for tasks without requirements.

        // SSH scheduler doesn't support multiple requirements
        if (task->getNofRequirements() > 1)
        {
            stringstream ss;
            ss << "Unable to schedule task <" << id << "> with path " << task->getPath()
               << ": SSH scheduler doesn't support multiple requirements.";
            throw runtime_error(ss.str());
        }

        CTopoRequirement::Ptr_t requirement = (task->getNofRequirements() == 1) ? task->getRequirements()[0] : nullptr;
        if ((useRequirement && requirement == nullptr) || (!useRequirement && requirement != nullptr))
            continue;

        bool taskAssigned = false;

        for (auto& v : _hostToChannelMap)
        {
            const bool requirementOk = checkRequirement(requirement, useRequirement, v.first.first, v.first.second);
            if (requirementOk)
            {
                if (!v.second.empty())
                {
                    size_t channelIndex = v.second.back();
                    const auto& channel = _channels[channelIndex];

                    SSchedule schedule;
                    schedule.m_weakChannelInfo = channel;
                    schedule.m_taskInfo = it->second;
                    schedule.m_taskID = id;
                    m_schedule.push_back(schedule);

                    v.second.pop_back();

                    taskAssigned = true;

                    break;
                }
            }
        }
        if (!taskAssigned)
        {
            LOG(debug) << toString();
            stringstream ss;
            string requirementStr = (useRequirement)
                                        ? ("Requirement " + requirement->getName() + " couldn't be satisfied.")
                                        : "Not enough worker nodes.";
            ss << "Unable to schedule task <" << id << "> with path " << task->getPath() << ".\n" << requirementStr;
            throw runtime_error(ss.str());
        }
    }
}
开发者ID:AnarManafov,项目名称:DDS,代码行数:81,代码来源:SSHScheduler.cpp

示例15: removeParDeadEndNodes

/*
 * ===  FUNCTION  ======================================================================
 *         Name:  removeDeadEndNodes
 *  Description:  remove dead end nodes and their incident edges
 * =====================================================================================
 */
UINT64 OverlapGraphSimple::removeParDeadEndNodes(map<UINT64, t_edge_vec* > *parGraph, set<UINT64> &markedNodes, vector<UINT64> &nodeList)
{
	CLOCKSTART;
	vector<UINT64> nodes_to_remove;
	#pragma omp parallel for schedule(dynamic) num_threads(p_ThreadPoolSize)
	for(size_t i=0; i<nodeList.size(); i++)
	{
		map<UINT64, vector<EdgeSimple*> * >::iterator it=parGraph->find(nodeList[i]);
		if(!it->second->empty())	// If the read has some edges.
		{
			bool isDeadEnd = true;	// flag for dead end edge
			UINT64 inEdge = 0; 	// number of incoming edges to this node
			UINT64 outEdge = 0; 	// number of outgoing edges from this node

			// Find number of in- and out- edges
			for(UINT64 j=0; j < it->second->size(); j++)
			{
				EdgeSimple * edge = it->second->at(j);

				//If edge points to a node not marked in this partition donot assume dead end delete it.
				UINT64 destID = edge->getDestinationRead();
				if(markedNodes.find(destID) == markedNodes.end())
				{
					isDeadEnd = false;
					break;
				}
				/* Break case:
				 * 0. edge already marked as not dead end
				 * 1. composite edge with more than minReadsCountInEdgeToBeNotDeadEnd (deafult: 10)
				 * 2. composite edge longer than minEdgeLengthToBeNotDeadEnd (default: 500)
				 * 3. the edge is loop for the current node
				 * Then flag=1 and exit the loop
				 */

				if (edge->isNotDeadEnd()){
					isDeadEnd = false;
					break;
				}
				if(edge->isListofReads() && edge->getListofReadsSize() >= minReadsCountInEdgeToBeNotDeadEnd) {
					edge->markNotDeadEnd();
					isDeadEnd = false;
					break;
				}
				if(edge->getEdgeLength() >= minEdgeLengthToBeNotDeadEnd) {
					edge->markNotDeadEnd();
					isDeadEnd = false;
					break;
				}
				if(edge->isLoop())
				{
					edge->markNotDeadEnd();
					isDeadEnd = false;
					break;
				}

				if((edge->getOrientation() >> 1) & 1)
					++outEdge;
				else
					++inEdge;
			}
			// no good edges incident to the node and only in-edges or out-edges
			if( isDeadEnd && inEdge*outEdge == 0 && inEdge + outEdge > 0){
				#pragma omp critical(updateNodeList)
				{
					nodes_to_remove.push_back(it->first);
				}
			}
		}
开发者ID:abiswas-odu,项目名称:Omega3,代码行数:74,代码来源:OverlapGraphSimple.cpp


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