本文整理汇总了C++中IntervalSet::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ IntervalSet::empty方法的具体用法?C++ IntervalSet::empty怎么用?C++ IntervalSet::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IntervalSet
的用法示例。
在下文中一共展示了IntervalSet::empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(IntervalTest, EmptyInterval)
{
Interval<int> i1 = (Bound<int>::closed(1), Bound<int>::open(0));
EXPECT_EQ(1, i1.lower());
EXPECT_EQ(0, i1.upper());
Interval<int> i2 = (Bound<int>::open(1), Bound<int>::closed(0));
EXPECT_EQ(2, i2.lower());
EXPECT_EQ(1, i2.upper());
Interval<int> i3 = (Bound<int>::open(0), Bound<int>::open(0));
EXPECT_EQ(1, i3.lower());
EXPECT_EQ(0, i3.upper());
Interval<int> i4 = (Bound<int>::closed(3), Bound<int>::closed(2));
EXPECT_EQ(3, i4.lower());
EXPECT_EQ(3, i4.upper());
IntervalSet<int> set;
set += i1;
EXPECT_TRUE(set.empty());
EXPECT_EQ(0u, set.intervalCount());
set += i2;
EXPECT_TRUE(set.empty());
EXPECT_EQ(0u, set.intervalCount());
set += i3;
EXPECT_TRUE(set.empty());
EXPECT_EQ(0u, set.intervalCount());
set += i4;
EXPECT_TRUE(set.empty());
EXPECT_EQ(0u, set.intervalCount());
set += (Bound<int>::closed(2), Bound<int>::closed(2));
EXPECT_TRUE(set.contains(2));
EXPECT_EQ(1u, set.size());
EXPECT_EQ(1u, set.intervalCount());
set += (Bound<int>::closed(0), Bound<int>::open(1));
EXPECT_TRUE(set.contains(0));
EXPECT_TRUE(set.contains(2));
EXPECT_EQ(2u, set.size());
EXPECT_EQ(2u, set.intervalCount());
}
示例2: while
bool is_disjoint
(
interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object,
const IntervalSet <DomainT,Interval,Compare,Alloc>& operand
)
{
typedef interval_base_set<SubType,DomainT,Interval,Compare,Alloc> object_type;
typedef IntervalSet <DomainT,Interval,Compare,Alloc> operand_type;
object_type intersection;
if(operand.empty())
return true;
typename operand_type::const_iterator common_lwb;
typename operand_type::const_iterator common_upb;
if(!Set::common_range(common_lwb, common_upb, operand, object))
return true;
typename operand_type::const_iterator it = common_lwb;
while(it != common_upb)
{
object.add_intersection(intersection, *it++);
if(!intersection.empty())
return false;
}
return true;
}
示例3:
typename IntervalSet<DomainT,Interval,Compare,Alloc>::interval_type
enclosure(const IntervalSet<DomainT,Interval,Compare,Alloc>& object)
{
typedef IntervalSet<DomainT,Interval,Compare,Alloc> IntervalSetT;
typedef typename IntervalSetT::interval_type interval_type;
return
object.empty() ? neutron<interval_type>::value()
: (*object.begin()).span(*object.rbegin());
}
示例4: make_pair
pair<DataType, DataType> get_range(IntervalSet& interval, int dimIndex)
{
assert(!interval.empty());
int beginIndex = *interval.begin();
IntervalSet::iterator end = interval.end();
--end;
int endIndex = *end;
assert(beginIndex >= 0 && beginIndex < (int)g_data.size());
assert(endIndex >= 0 && endIndex < (int)g_data.size());
return make_pair(
g_data[beginIndex].first[dimIndex],
g_data[endIndex].first[dimIndex]);
}