本文整理汇总了C++中Paths::push方法的典型用法代码示例。如果您正苦于以下问题:C++ Paths::push方法的具体用法?C++ Paths::push怎么用?C++ Paths::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paths
的用法示例。
在下文中一共展示了Paths::push方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clone
Paths* clone() {
Paths* ps = new Paths();
for (int i=0;i<this->size();i++) {
ps->push(paths[i]->clone());
}
return ps;
}
示例2: getPathFrom
Paths* getPathFrom(string c) {
Paths* ps = new Paths();
for (int i=0; i<paths.size(); i++) {
if (paths[i]->c1 == c || paths[i]->c2 == c) {
ps->push(paths[i]);
}
}
return ps;
}
示例3: main
int main(int argc, char** argv) {
int n, m;
int val;
string c, c1, c2;
// initialize & input
cin>>n>>m;
Citys citys(n);
Paths paths;
SpanningPaths spanning_path;
for(int i=0;i<n;i++) {
cin >> c;
citys.setName(i, c);
}
for(int i=0;i<m;i++) {
cin>>c1>>c2>>val;
paths.push(new Path(c1, c2, val));
}
// kruskal's algo
paths.sortByCost();
for (int i=0; i<paths.size(); i++) {
Path* p = paths.at(i);
if (!spanning_path.existRingIfAdd(p)) {
spanning_path.push(p->clone());
}
}
int total_cost = 0;
for (int i=0; i<spanning_path.size(); i++) {
Path* p = spanning_path.at(i);
cout << "(" << p->c1 << " " << p->c2 << ") ";
total_cost += p->cost;
}
cout << "\n" << total_cost << endl;
// paths.list();
// spanning_path.list();
return 0;
}
示例4: SolveDir
void SolveDir( fs::path & dirName)
{
// Get all files in this dir
// loop through them
LOG( "Entering DIRECTORY: " << dirName);
fs::directory_iterator end_iter;
for ( fs::directory_iterator dir_itr( dirName );
dir_itr != end_iter;
++dir_itr )
{
// if it is subdir, call itself on subdir
if ( fs::is_directory( dir_itr->status() ) )
{
paths.push( *dir_itr);
}
else
{
entryCont.SolveFile( dir_itr->string(), dirName.string() );
}
}
}
示例5: full_path
int
main( int argc, char** argv)
{
fs::path full_path( fs::initial_path<fs::path>() );
if ( argc > 1 )
full_path = fs::system_complete( fs::path( argv[1], fs::native ) );
else
PrintUsage();
// specification of hi, low date of studies
if( argc > 2)
{
string s(argv[2]);
if( s.compare( "--info") == 0 )
{
entryCont.infoOnly = true;
}
else
{
if( argc > 3)
{
entryCont.dateFrom = argv[2];
entryCont.dateTo = argv[3];
}
else
PrintUsage();
}
}
// recursively (through queue) go through all files in subtree
// of specified directory specified
try {
if ( fs::is_directory( full_path ) )
{
paths.push( full_path);
}
else // must be a file
{
entryCont.SolveFile( full_path.string(), "buddy" );
}
fs::path currPath;
while( ! paths.empty() )
{
currPath = paths.front();
SolveDir( currPath);
paths.pop(); // remove this dir from queue
}
} catch( std::exception &ex) {
LOG( ex.what());
}
// flush info
{
ofstream o("output.txt");
entryCont.FlushMaps( o);
o.close();
}
return 0;
}