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


C++ SearchPointVector::push_back方法代码示例

本文整理汇总了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;
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:30,代码来源:GrahamScan.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例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));
}
开发者ID:Mrdini,项目名称:XCSoar,代码行数:32,代码来源:OLCSISAT.cpp

示例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;
  }
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:37,代码来源:GrahamScan.cpp


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