Example #1
0
 inline std::string PrettyPrint(const std::unordered_multimap<A, B, Hash, Predicate, Allocator>& maptoprint, const bool add_delimiters=false, const std::string& separator=", ")
 {
     std::ostringstream strm;
     if (maptoprint.size() > 0)
     {
         if (add_delimiters)
         {
             strm << "{";
             typename std::unordered_multimap<A, B, Hash, Predicate, Allocator>::const_iterator itr;
             for (itr = maptoprint.begin(); itr != maptoprint.end(); ++itr)
             {
                 std::pair<A, B> cur_pair(itr->first, itr->second);
                 if (itr != maptoprint.begin())
                 {
                     strm << separator << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
                 else
                 {
                     strm << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
             }
             strm << "}";
         }
         else
         {
             typename std::unordered_multimap<A, B, Hash, Predicate, Allocator>::const_iterator itr;
             for (itr = maptoprint.begin(); itr != maptoprint.end(); ++itr)
             {
                 std::pair<A, B> cur_pair(itr->first, itr->second);
                 if (itr != maptoprint.begin())
                 {
                     strm << separator << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
                 else
                 {
                     strm << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
             }
         }
     }
     return strm.str();
 }
	sf::RenderTexture* ShadowTextRenderer::findFromTextureCache(sf::Vector2u size)
	{
		auto it = shadowCache.find(size);

		if (it != shadowCache.end())
		{
			auto ptr = it->second;
			shadowCache.erase(it);
			return ptr;
		}

		return 0;
	}
Example #3
0
//calculate the given dynamical-network's maxminum B and its corresponding w
std::pair<int,double> calmaxBW(std::unordered_multimap<int,std::pair<int,int>> &SN)
{
  int maxB = 0,temp,attractor = 0;
  double Wn;
  for(auto it = SN.begin(); it != SN.end(); it++){
    if(it->first == it->second.first){
      temp = calBRec(SN,it->second.first);
      if(temp > maxB){
	maxB = temp;
	attractor = it->first;//main attractor
      }
    }
  }
  Wn = calWRec(SN,attractor,1,0);
  return std::make_pair(maxB,Wn/maxB);
}
//find the maximum B:basin for a given directed network
std::pair<int,double> findMaxBW(std::unordered_multimap<int,std::pair<int,int>> &SN,double *TF)
{
  int maxB = 0,temp,attractor = 0;
  double Wn;
  for(auto it = SN.begin(); it != SN.end(); it++){
    /**!!!!!!!!!!!your must change attractor!!!!!!!!**/
    if(it->first == it->second.first && it->first == 76){
      temp = findMaxBRec(SN,it->second.first,TF);
      if(temp > maxB){
	maxB = temp;
	attractor = it->first;//main attractor
      }
    }
  }
  Wn = calWRec(SN,attractor,1,0);
  return std::make_pair(maxB,Wn/maxB);
}