Range Class Reference

to specify 1-dim region or range by two floats More...

#include <Range.h>

List of all members.

Public Member Functions

 Range ()
 Constructor.
 Range (const Range &)
 Copy constructor.
 Range (float low, float high)
 Constructor.
virtual float low (void) const
 returns lower limit.
virtual float high (void) const
 returns higher limit.
virtual float center (void) const
 returns center.
virtual float width (void) const
 returns width.
virtual float low (float lowIn)
 sets lower limit.
virtual float high (float highIn)
 sets higher limit.
virtual Rangeset (float low, float high)
 sets range.
virtual RangesetByCenter (float center, float width)
 sets range by center and width.
Rangeoperator= (const Range &)
 Copy operator.
bool operator== (const Range &) const
 returns true if range is the same.
bool operator!= (const Range &) const
 returns true if range is different.
bool operator & (const Range &) const
 returns true if two are overlaped each other.
bool within (const float value) const
 returns true if given value is within a range.
bool within2 (const float value) const
 returns true if given value is within a range.
bool within (const Range &) const
 returns true if given Range is within(included in) a range.
virtual int dump (void) const
 displays debug information.

Private Attributes

float _low
 Lower limit.
float _high
 Higher limit.


Detailed Description

to specify 1-dim region or range by two floats

Definition at line 19 of file Range.h.


Constructor & Destructor Documentation

Range::Range (  ) 

Constructor.

Definition at line 16 of file Range.cxx.

References _high, and _low.

00016              {
00017     _low = -999.;
00018     _high = -999.;
00019 }

Range::Range ( const Range  ) 

Copy constructor.

Definition at line 21 of file Range.cxx.

References _high, _low, high(), and low().

00021                              {
00022     _low = ib.low();
00023     _high = ib.high();
00024 }

Range::Range ( float  low,
float  high 
)

Constructor.

Definition at line 26 of file Range.cxx.

References _high, and _low.

00026                                                 {
00027     if (iHigh > iLow) {
00028         _low = iLow;
00029         _high = iHigh;
00030     }
00031     else {
00032         _low = iHigh;
00033         _high = iLow;
00034     }
00035 }


Member Function Documentation

float Range::center ( void   )  const [inline, virtual]

returns center.

Definition at line 129 of file Range.h.

References _high, and _low.

00129                         {
00130     return (_low + _high) / 2.;
00131 }

int Range::dump ( void   )  const [virtual]

displays debug information.

Definition at line 45 of file Range.cxx.

References _high, and _low.

00045                       {
00046     std::cout << _low << "~" << _high;
00047     return 0;
00048 }

float Range::high ( float  highIn  )  [inline, virtual]

sets higher limit.

Definition at line 122 of file Range.h.

References _high, and _low.

00122                    {
00123     if (i < _low) i = _low;
00124     return _high = i;
00125 }

float Range::high ( void   )  const [inline, virtual]

returns higher limit.

Definition at line 116 of file Range.h.

References _high.

Referenced by operator &(), operator=(), operator==(), Range(), and within().

00116                       {
00117     return _high;
00118 }

float Range::low ( float  lowIn  )  [inline, virtual]

sets lower limit.

Definition at line 109 of file Range.h.

References _high, and _low.

00109                   {
00110     if (i > _high) i = _high;
00111     return _low = i;
00112 }

float Range::low ( void   )  const [inline, virtual]

returns lower limit.

Definition at line 103 of file Range.h.

References _low.

Referenced by operator &(), operator=(), operator==(), Range(), and within().

00103                      {
00104     return _low;
00105 }

bool Range::operator & ( const Range  )  const [inline]

returns true if two are overlaped each other.

Definition at line 212 of file Range.h.

References high(), low(), and within().

00212                                         {
00213     if (within(a.low())) return true;
00214     if (within(a.high())) return true;
00215     if (a.within(low())) return true;
00216     if (a.within(high())) return true;
00217     return false;
00218 }

bool Range::operator!= ( const Range  )  const [inline]

returns true if range is different.

Definition at line 205 of file Range.h.

00205                                          {
00206     if ((* this) == a) return false;
00207     return true;
00208 }

Range & Range::operator= ( const Range  )  [inline]

Copy operator.

Definition at line 163 of file Range.h.

References _high, _low, high(), and low().

00163                                    {
00164     _low = ib.low();
00165     _high = ib.high();
00166     return * this;
00167 }

bool Range::operator== ( const Range  )  const

returns true if range is the same.

Definition at line 38 of file Range.cxx.

References _high, _low, high(), and low().

00038                                          {
00039     if (_low != a.low()) return false;
00040     if (_high != a.high()) return false;
00041     return true;
00042 }

Range & Range::set ( float  low,
float  high 
) [inline, virtual]

sets range.

Definition at line 141 of file Range.h.

References _high, and _low.

00141                                   {
00142     if (iHigh > iLow) {
00143         _low = iLow;
00144         _high = iHigh;
00145     }
00146     else {
00147         _low = iHigh;
00148         _high = iLow;
00149     }
00150     return * this;
00151 }

Range & Range::setByCenter ( float  center,
float  width 
) [inline, virtual]

sets range by center and width.

Definition at line 155 of file Range.h.

References _high, and _low.

00155                                             {
00156     _low = center - width;
00157     _high = center + width;
00158     return * this;
00159 }

float Range::width ( void   )  const [inline, virtual]

returns width.

Definition at line 135 of file Range.h.

References _high, and _low.

00135                        {
00136     return (_high - _low);
00137 }

bool Range::within ( const Range  )  const [inline]

returns true if given Range is within(included in) a range.

Definition at line 222 of file Range.h.

References high(), low(), and within().

00222                                    {
00223     if (within(a.low()) && within(a.high())) return true;
00224     return false;
00225 }

bool Range::within ( const float  value  )  const [inline]

returns true if given value is within a range.

Definition at line 171 of file Range.h.

References _high, and _low.

Referenced by operator &(), and within().

00171                                 {
00172     if (_low == -999. && _high == -999.) {
00173         return false;
00174     }
00175     if (_low == -999.) {
00176         if (f <= _high) return true;
00177         return false;
00178     }
00179     if (_high == -999.) {
00180         if (f >= _low) return true;
00181     }
00182     if (f >= _low && f <= _high) return true;
00183     return false;
00184 }

bool Range::within2 ( const float  value  )  const [inline]

returns true if given value is within a range.

Definition at line 188 of file Range.h.

References _high, and _low.

00188                                  {
00189     if (_low == -999. && _high == -999.) {
00190         return true;
00191     }
00192     if (_low == -999.) {
00193         if (f <= _high) return true;
00194         return false;
00195     }
00196     if (_high == -999.) {
00197         if (f >= _low) return true;
00198     }
00199     if (f >= _low && f <= _high) return true;
00200     return false;
00201 }


Member Data Documentation

float Range::_high [private]

Higher limit.

Definition at line 87 of file Range.h.

Referenced by center(), dump(), high(), low(), operator=(), operator==(), Range(), set(), setByCenter(), width(), within(), and within2().

float Range::_low [private]

Lower limit.

Definition at line 85 of file Range.h.

Referenced by center(), dump(), high(), low(), operator=(), operator==(), Range(), set(), setByCenter(), width(), within(), and within2().


Generated on Tue Nov 29 23:20:44 2016 for BOSS_7.0.2 by  doxygen 1.4.7