CMS 3D CMS Logo

Functions
rangesIntersect.h File Reference

Go to the source code of this file.

Functions

template<class Range >
bool rangesIntersect (const Range &a, const Range &b)
 
template<class Range , class Less >
bool rangesIntersect (const Range &a, const Range &b, const Less &less)
 

Function Documentation

template<class 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.

Referenced by TECLayer::addClosest(), LayerCollector::allLayers(), OuterDetCompatibility::checkPhi(), OuterDetCompatibility::checkR(), OuterDetCompatibility::checkZ(), ConversionBarrelEstimator::estimate(), ForwardMeasurementEstimator::estimate(), BarrelMeasurementEstimator::estimate(), PixelRecoRange< float >::hasIntersection(), barrelUtil::overlap(), tkDetUtil::overlapInPhi(), and StartingLayerFinder::startingLayers().

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

Definition at line 20 of file rangesIntersect.h.

21  {
22  if ( less(b.second,a.first) || less(a.second,b.first)) return false;
23  else return true;
24 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121