本文整理匯總了C++中Interval::A方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::A方法的具體用法?C++ Interval::A怎麽用?C++ Interval::A使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Interval
的用法示例。
在下文中一共展示了Interval::A方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: assert
// this function implements efficient counting of intersections
// with logarithmic running time in the worst case;
// for implementation details of this method see documentation;
int CountIntersections
(
Interval const & interval_x ,
MultiSetInt const & mset_a ,
MultiSetInt const & mset_b
)
{
assert ( mset_a.size()==mset_b.size() ) ;
int n = mset_a . size ( ) ;
int n_a = mset_b . upper_bound ( interval_x.A() ) -
mset_b . begin ( ) ;
int n_b = mset_a . end ( ) -
mset_a . lower_bound ( interval_x.B() ) ;
int count = n - n_a - n_b ;
return count ;
}
示例2: Intersect
// this function detects intersection of two intervals,
// it returns true in the following cases:
// - both intervals are non-empty and their intersection
// is a non-empty interval ;
// - an empty interval is in the interior of the other
// non-empty interval ;
// in all other cases this functions returns false ;
bool Intersect ( Interval const & x , Interval const & y )
{
return ( x.A() < y.B() ) && ( y.A() < x.B() ) ;
}