本文整理汇总了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));
}
示例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());
}
示例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;
}