本文整理汇总了C++中Segment::cost方法的典型用法代码示例。如果您正苦于以下问题:C++ Segment::cost方法的具体用法?C++ Segment::cost怎么用?C++ Segment::cost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment::cost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printPathList
void Conn::printPathList(PathList& paths, Fleet::Ptr _fleet)
{
// cout << "\n\nPrinting path list \n\n";
while(!paths.empty())
{
Cost cost(0);
Time time(0);
bool exp = true;
Path p = paths.front();
Path::iterator it = p.begin();
for(; it != p.end(); it++)
{
Segment* seg = *it;
cost = cost + seg->cost(_fleet);
time = time + seg->time(_fleet);
if(!seg->expediteSupport()) exp = false;
}
cout << cost.string() << " " << time.string() << " " << (exp?"yes; ":"no; ");
Conn::printPath(paths.front());
cout << "\n";
paths.pop();
}
}
示例2: path
Conn::StatPathList Conn::path(Fleet::Ptr _fleet, Location::Ptr _source, Cost _cost, Mile _distance, bool _expedite, Time _time )
{
Conn::StatPathList paths;
Conn::StatPathList results;
vector<SegmentPtr> segments = _source->segments();
vector<SegmentPtr>::iterator it = segments.begin();
// These are running variables
Cost cost = 0;
Mile distance = 0;
bool expedite = _expedite;
Time time = 0;
for(; it != segments.end(); it++)
{
SegmentPtr ret = (*it)->returnSegment();
if(ret)
{
if(ret->source())
{
Segment* seg = (*it).ptr();
if(_expedite == seg->expediteSupport())
{
Conn::StatPath* p = new StatPath();
p->path()->push_back( (*it ).ptr());
p->costIs(seg->cost(_fleet));
p->distanceIs(seg->length());
p->expediteIs(expedite);
p->timeIs(time);
paths.push(p);
}
}
}
}
int i = 0;
// cerr << "Before entering size is: " << paths.size() << "\n";
while(!paths.empty())
{
std::cerr << "called " << i++ << "\n";
StatPath*& p = paths.front();
StatPath* rp = new StatPath();
//rp->path_ = new Path(*(p->path()));
rp->pathIs(new Path(*(p->path())));
results.push(rp);
Segment*& last_edge = p->path()->back();
Segment::Ptr ret = last_edge->returnSegment();
// cerr << "Return Segment offront segment is: " << ret->name() << "\n";
Location::Ptr dest = ret->source();
cerr << "Its destination: " << dest->name() << "\n";
if(nodeExistsInPath(dest, *(p->path())))
{
cerr << "Dest already Exists" << endl;
paths.pop();
continue;
}
vector<SegmentPtr> segments = dest->segments();
vector<SegmentPtr>::iterator it = segments.begin();
cerr << "No of new segments considered: " << segments.size() << endl;
for(; it != segments.end(); it++)
{
SegmentPtr seg = *it;
SegmentPtr ret = seg->returnSegment();
if(!ret)
{
//paths.pop();
continue;
}
else
{
if(!ret->source())
{
//paths.pop();
continue;
}
else
{
if(nodeExistsInPath(ret->source(), *(p->path())))
{
//paths.pop();
continue;
}
StatPath* p1 = new StatPath(*p);
if( ((_expedite == false )|| ( (_expedite == true) && (_expedite == p->expedite()) ) )&&
( (_cost == Cost::nil()) || ( _cost != Cost::nil() && (( p->cost() + seg->cost(_fleet)) <= _cost ) ) )&&
( (_distance == Mile::nil()) || ( _distance != Mile::nil() && ( (p->distance() + seg->length()) <= _distance) ) )&&
//.........这里部分代码省略.........