CMS 3D CMS Logo

Functions
rangesIntersect.h File Reference

Go to the source code of this file.

Functions

template<typename Range >
bool rangesIntersect (const Range &a, const Range &b)
 
template<typename Range , typename Less >
bool rangesIntersect (const Range &a, const Range &b, Less const &less)
 
template<typename Range , typename T >
bool rangesIntersect (const Range &a, const Range &b, bool(*less)(T, T))
 

Function Documentation

template<typename Range >
bool rangesIntersect ( const Range a,
const Range b 
)
inline

Utility for checking efficiently if two one-dimantional intervals intersect. Precondition: the intervals are not empty, i.e. for i in a,b i.first <= i.second. The Range template argument is expected to have the std::pair interface, i.e. for Range instance r r.first is the beginning of the interval and r.second is the end of the interval.

Definition at line 14 of file rangesIntersect.h.

14  {
15  return !( (a.first > b.second) | (b.first > a.second) );
16 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
template<typename Range , typename Less >
bool rangesIntersect ( const Range a,
const Range b,
Less const &  less 
)
inline

Definition at line 19 of file rangesIntersect.h.

20  {
21  return !( less(b.second,a.first) | less(a.second,b.first));
22 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
template<typename Range , typename T >
bool rangesIntersect ( const Range a,
const Range b,
bool(*)(T, T less 
)
inline

Definition at line 24 of file rangesIntersect.h.

25  {
26  return !( less(b.second,a.first) | less(a.second,b.first));
27 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121