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


C++ list::merge方法代码示例

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


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

示例1: findFiles

void FileSource::findFiles(fs::path dir, std::list<fs::path>& paths, std::string extn) {
    std::list<std::list<fs::path>> branch_paths;
    if (fs::exists(dir) && fs::is_directory(dir)) {
        boost::thread_group threads;
	fs::directory_iterator end_itr;
	for(fs::directory_iterator itr(dir); itr != end_itr; ++itr) {
	    if (fs::is_regular_file(itr->status())) {
		if (itr->path().extension() == extn) {
                    //cout<<itr->path()<<endl;
		    paths.push_back(itr->path());
                }
	    } else if (fs::is_directory(itr->status())) {
		std::list<fs::path> leaf;
		branch_paths.push_back(leaf);
		threads.create_thread(boost::bind(&FileSource::findFiles, this, itr->path(), boost::ref(branch_paths.back()), extn));
	    }
	}
        threads.join_all();

        if (branch_paths.size())
         {
           for(auto& path : branch_paths)
               paths.merge(path);
         }
    }
}
开发者ID:SabyTech,项目名称:file-indexer,代码行数:26,代码来源:FileSource.cpp

示例2: child_merge

void Map::child_merge(std::list<Entity *> &pull_) {
    if (level == MAX_LEVEL) {
        if (!pull.empty()) {
            pull_.merge(pull);
            count = 0;
        }
        return;
    }
    if (!pull.empty()) {
        pull_.merge(pull);
        count = 0;
    }
    NW->child_merge(pull);
    NE->child_merge(pull);
    SW->child_merge(pull);
    SE->child_merge(pull);
}
开发者ID:Valeryn4,项目名称:life-001,代码行数:17,代码来源:map.cpp

示例3: Proc

 void MatchPool::Proc(std::list<MatchRes> &resList) {
     std::map<int, MatchPool*>::iterator itr;
     for (itr = s_pools.begin(); itr != s_pools.end(); ++itr) {
         std::list<MatchRes> tmpList;;
         if (itr->second->tick(tmpList)) {
             resList.merge(tmpList);
         }
     }
 }
开发者ID:yulefox,项目名称:elfox,代码行数:9,代码来源:matchmaking.cpp

示例4: addDepends

bool addDepends(std::list<IDownload*>& dls)
{
	std::list<IDownload*>::iterator it;
	for (it = dls.begin(); it != dls.end(); ++it) {
		if ((*it)->depend.empty()) {
			continue;
		}
		std::list<std::string>::iterator stit;
		for (stit = (*it)->depend.begin(); stit != (*it)->depend.end(); ++stit) {
			std::list<IDownload*> depends;
			const std::string& depend = (*stit);
			search(DL_ANY, CAT_ANY, depend.c_str(), depends);
			LOG_INFO("Adding depend %s", depend.c_str());
			dls.merge(depends);
		}
	}
	return true;
}
开发者ID:AppSynergy,项目名称:pr-downloader,代码行数:18,代码来源:pr-downloader.cpp

示例5: runLabelSetting

//LABELSETTING
long int runLabelSetting(std::vector<Box*> &vectorBox, Data &data, std::list<Solution> & allSolution)
{
    std::vector<Box*>::iterator itVector;
    for (itVector = vectorBox.begin(); itVector != vectorBox.end(); ++itVector)
    {
        LabelSetting m(*(*itVector));
        m.compute();

        allSolution.merge(m.nodes_[m.getRank() - 1].labels_);
    }

    filterListSolution(allSolution);

    if (Argument::mode_export)
    {
        ToFile::saveYN(allSolution, data);
    }

    return (long int) allSolution.size();
}
开发者ID:charlyisidore,项目名称:mocflp,代码行数:21,代码来源:Functions.cpp

示例6: runMOGA

// Multi-objective genetic algorithm
long int runMOGA(std::vector<Box*> &vectorBox, Data &data, std::list<Solution> & allSolution)
{
    std::vector<Box*>::iterator itVector;
    FILE * pipe_fp = 0; // Gnuplot pipe
    int object_id = 0;

    // OPEN GNUPLOT (interactive mode)
    if (Argument::interactive)
    {
        if ( ( pipe_fp = popen("gnuplot", "w") ) != 0 )
        {
            int num_obj = (*vectorBox.begin())->getNbObjective();
            std::vector<double> minZ( num_obj, std::numeric_limits<double>::infinity() ),
                maxZ( num_obj, -std::numeric_limits<double>::infinity() );

            for (itVector = vectorBox.begin(); itVector != vectorBox.end(); ++itVector)
            {
                for ( int k = 0; k < (*(*itVector)).getNbObjective(); ++k )
                {
                    minZ[k] = std::min( (*(*itVector)).getMinZ( k ), minZ[k] );
                    maxZ[k] = std::max( (*(*itVector)).getMaxZ( k ), maxZ[k] );
                }
            }

            fputs( "set nokey\n", pipe_fp );
            fputs( "set xlabel \"$z_1$\"\n", pipe_fp );
            fputs( "set ylabel \"$z_2$\"\n", pipe_fp );
            fprintf( pipe_fp, "set xrange [%f:%f]\n", minZ[0], maxZ[0] );
            fprintf( pipe_fp, "set yrange [%f:%f]\n", minZ[1], maxZ[1] );
        }
        else
        {
            std::cerr << "Error: gnuplot pipe failed" << std::endl;
        }
    }

    // Apply MOGA on each box
    for (itVector = vectorBox.begin(); itVector != vectorBox.end(); ++itVector)
    {
        // Draw the box associated
        if ( pipe_fp )
        {
            ++object_id;
            fprintf( pipe_fp, "set object %d rectangle from %f,%f to %f,%f fillstyle empty\n", object_id,
                     (*(*itVector)).getMinZ(0), (*(*itVector)).getMinZ(1),
                     (*(*itVector)).getMaxZ(0), (*(*itVector)).getMaxZ(1) );
        }

        MOGA m(*(*itVector), Argument::num_individuals, Argument::num_generations, Argument::Pc, Argument::Pm);
        m.pipe_fp_ = pipe_fp;
        m.compute();

        allSolution.merge(m.solutions_);
    }

    // CLOSE GNUPLOT
    if ( pipe_fp )
    {
        pclose(pipe_fp);
    }

    // FILTERING DOMINATED SOLUTIONS
    for ( std::list<Solution>::iterator it1 = allSolution.begin(); it1 != allSolution.end(); ++it1 )
    {
        for ( std::list<Solution>::iterator it2 = it1; it2 != allSolution.end(); ++it2 )
        {
            bool dominates = true, dominated = true;
            for (int k = 0; k < (*it1).getNbObjective() && (dominates || dominated); ++k)
            {
                if ( !( (*it1).getObj( k ) < (*it2).getObj( k ) ) )
                    dominates = false;

                if ( !( (*it2).getObj( k ) < (*it1).getObj( k ) ) )
                    dominated = false;
            }
            if ( dominates )
            {
                it2 = allSolution.erase( it2 );
                --it2;
            }
            if ( dominated )
            {
                it1 = allSolution.erase( it1 );
                --it1;
                break;
            }
        }
    }

    if (Argument::mode_export)
    {
        ToFile::saveYN(allSolution, data);
    }

    return (long int) allSolution.size();
}
开发者ID:charlyisidore,项目名称:mocflp,代码行数:97,代码来源:Functions.cpp


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