本文整理汇总了C++中IntervalSet::size方法的典型用法代码示例。如果您正苦于以下问题:C++ IntervalSet::size方法的具体用法?C++ IntervalSet::size怎么用?C++ IntervalSet::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IntervalSet
的用法示例。
在下文中一共展示了IntervalSet::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(IntervalTest, Intersection)
{
IntervalSet<int> set;
set += (Bound<int>::closed(1), Bound<int>::closed(3));
EXPECT_TRUE(set.contains(1));
EXPECT_EQ(1u, set.intervalCount());
EXPECT_EQ(3u, set.size());
set &= (Bound<int>::open(1), Bound<int>::open(5));
EXPECT_FALSE(set.contains(1));
EXPECT_EQ(1u, set.intervalCount());
EXPECT_EQ(2u, set.size());
IntervalSet<int> set2;
set2 += 6;
set &= set2;
EXPECT_TRUE(set.empty());
EXPECT_EQ(0u, set.intervalCount());
}
示例2: chisquared_interval
// Compute $\chi^2$ value for an interval
float chisquared_interval(IntervalSet& interval)
{
// Count instances of each class
map<ClassType, int> classCount;
IntervalSet::iterator it = interval.begin(),
end = interval.end();
for ( ; it != end; ++it) {
int index = *it;
ClassType classType = g_data[index].second;
classCount[classType]++;
}
// Keep track of summation
float chichiri = 0.0f;
set<ClassType>::iterator sit = g_classTypes.begin(),
send = g_classTypes.end();
for ( ; sit != send; ++sit) {
ClassType classType = *sit;
// Uses notation from section 4.2.1,
// "Discretization: An Enabling Technique" by H. Liu et al.
float A_ij = static_cast<float>(classCount[classType]);
float R_i = static_cast<float>(interval.size());
float C_j = static_cast<float>(g_globalClassCount[classType]);
float N = static_cast<float>(g_data.size());
float E_ij = (R_i * C_j) / N;
float top = (A_ij - E_ij);
chichiri += top*top / E_ij;
}
cout << "{" << chichiri << "} + ";
return chichiri;
}