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


C++ TSet::size方法代码示例

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


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

示例1: Filter

void PreRanker::Filter(bool viewportSearch)
{
  using TSet = set<impl::PreResult1, LessFeatureID>;
  TSet theSet;

  sort(m_results.begin(), m_results.end(), ComparePreResult1());
  m_results.erase(unique(m_results.begin(), m_results.end(), EqualFeatureID()), m_results.end());

  sort(m_results.begin(), m_results.end(), &impl::PreResult1::LessDistance);

  if (m_limit != 0 && m_results.size() > m_limit)
  {
    // Priority is some kind of distance from the viewport or
    // position, therefore if we have a bunch of results with the same
    // priority, we have no idea here which results are relevant.  To
    // prevent bias from previous search routines (like sorting by
    // feature id) this code randomly selects tail of the
    // sorted-by-priority list of pre-results.

    double const last = m_results[m_limit - 1].GetDistance();

    auto b = m_results.begin() + m_limit - 1;
    for (; b != m_results.begin() && b->GetDistance() == last; --b)
      ;
    if (b->GetDistance() != last)
      ++b;

    auto e = m_results.begin() + m_limit;
    for (; e != m_results.end() && e->GetDistance() == last; ++e)
      ;

    // The main reason of shuffling here is to select a random subset
    // from the low-priority results. We're using a linear
    // congruential method with default seed because it is fast,
    // simple and doesn't need an external entropy source.
    //
    // TODO (@y, @m, @vng): consider to take some kind of hash from
    // features and then select a subset with smallest values of this
    // hash.  In this case this subset of results will be persistent
    // to small changes in the original set.
    minstd_rand engine;
    shuffle(b, e, engine);
  }
  theSet.insert(m_results.begin(), m_results.begin() + min(m_results.size(), m_limit));

  if (!viewportSearch)
  {
    size_t n = min(m_results.size(), m_limit);
    nth_element(m_results.begin(), m_results.begin() + n, m_results.end(),
                &impl::PreResult1::LessRank);
    theSet.insert(m_results.begin(), m_results.begin() + n);
  }

  m_results.reserve(theSet.size());
  m_results.clear();
  copy(theSet.begin(), theSet.end(), back_inserter(m_results));
}
开发者ID:igortomko,项目名称:omim,代码行数:57,代码来源:pre_ranker.cpp

示例2: TestCtorHelper

 void TestCtorHelper(TSet & set)
 {
     IS_TRUE(set.empty());
     IS_TRUE(set.size() == 0);
     IS_TRUE(set.begin() == set.end());
     IS_TRUE(set.cbegin() == set.cend());
     IS_TRUE(set.rbegin() == set.rend());
     IS_TRUE(set.crbegin() == set.crend());
 }
开发者ID:htiga,项目名称:LaiSTL,代码行数:9,代码来源:TestSet.cpp

示例3: operator

 bool operator()(const TSet& rTSet1, const TSet& rTSet2)const
 {
     if( rTSet1==rTSet2 ) {
         return false;
     }
     for(int i=0; i<rTSet1.size(); i++) {
         if( rTSet1[i]!=rTSet2[i] )
             return rTSet1[i]<rTSet2[i];
     }
     return false;
 }
开发者ID:tinyboyz,项目名称:consuegra,代码行数:11,代码来源:RexAlgorithm.cpp


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