本文整理汇总了C++中SearchPointVector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchPointVector::push_back方法的具体用法?C++ SearchPointVector::push_back怎么用?C++ SearchPointVector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchPointVector
的用法示例。
在下文中一共展示了SearchPointVector::push_back方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PartitionPoints
bool
GrahamScan::PruneInterior()
{
SearchPointVector res;
/* the result is usually one more than the input vector - is that a
bug? */
res.reserve(size + 1);
if (size < 3) {
std::copy(raw_points.begin(), raw_points.end(), std::back_inserter(res));
return false;
// nothing to do
}
PartitionPoints();
BuildHull();
for (unsigned i = 0; i + 1 < lower_hull.size(); i++)
res.push_back(*lower_hull[i]);
for (int i = upper_hull.size() - 1; i >= 0; i--)
res.push_back(*upper_hull[i]);
if (res.size() == size)
return false;
raw_vector.swap(res);
return true;
}
示例2: ApplyHandicap
ContestResult
OLCSISAT::CalculateResult(const ContestTraceVector &solution) const
{
// build convex hull from solution
SearchPointVector spv;
for (unsigned i = 0; i < num_stages; ++i)
spv.push_back(SearchPoint(solution[i].location));
spv.PruneInterior();
// now add leg distances making up the convex hull
fixed G = fixed_zero;
if (spv.size() > 1) {
for (unsigned i = 0; i + 1 < spv.size(); ++i)
G += spv[i].DistanceTo(spv[i + 1].GetLocation());
// closing leg (end to start)
G += spv[spv.size() - 1].DistanceTo(spv[0].GetLocation());
}
// R distance (start to end)
const fixed R = solution[0].DistanceTo(solution[num_stages - 1].GetLocation());
// V zigzag-free distance
const fixed V = G - R;
// S = total distance
ContestResult result = ContestDijkstra::CalculateResult(solution);
result.score = ApplyHandicap((V + 3 * result.distance) / 4000);
return result;
}
示例3: apply_handicap
fixed
OLCSISAT::calc_score() const
{
// build convex hull from solution
SearchPointVector spv;
for (unsigned i = 0; i < num_stages; ++i)
spv.push_back(solution[i]);
prune_interior(spv);
// now add leg distances making up the convex hull
fixed G = fixed_zero;
if (spv.size() > 1) {
for (unsigned i = 0; i + 1 < spv.size(); ++i)
G += spv[i].distance(spv[i + 1].get_location());
// closing leg (end to start)
G += spv[spv.size() - 1].distance(spv[0].get_location());
}
// R distance (start to end)
const fixed R = solution[0].distance(solution[num_stages - 1].get_location());
// V zigzag-free distance
const fixed V = G - R;
// S = total distance
const fixed S = calc_distance();
return apply_handicap((V + fixed(3) * S) * fixed(0.00025));
}
示例4:
bool
GrahamScan::prune_interior()
{
SearchPointVector res;
/* the result is usually one more than the input vector - is that a
bug? */
res.reserve(size + 1);
if (size<3) {
std::copy(raw_points.begin(), raw_points.end(),
std::back_inserter(res));
return false;
// nothing to do
}
partition_points();
build_hull();
for ( unsigned i = 0 ; i+1 < lower_hull.size() ; i++ ) {
res.push_back(*lower_hull[i]);
}
for ( int i = upper_hull.size()-1; i>=0 ; i-- ) {
res.push_back(*upper_hull[i]);
}
// if (!has_changed) {
// *changed = !std::equal(res.begin(), res.end(), raw_vector.begin() );
// }
if (res.size() != size) {
raw_vector.swap(res);
return true;
} else {
return false;
}
}