31 #include <boost/shared_ptr.hpp>
33 #include "../WTypeTraits.h"
41 template<
typename T >
48 typedef boost::shared_ptr< WInterval< T > >
SPtr;
53 typedef boost::shared_ptr< const WInterval< T > >
ConstSPtr;
166 template <
typename T1,
typename T2 >
182 template <
typename IntervalType,
typename T >
183 bool isInClosed(
const IntervalType& interval,
const T& value )
185 return ( ( interval.getLower() <= value ) && ( interval.getUpper() >= value ) );
198 template <
typename IntervalType,
typename T >
199 bool isInOpen(
const IntervalType& interval,
const T& value )
201 return ( ( interval.getLower() < value ) && ( interval.getUpper() > value ) );
214 template <
typename IntervalType,
typename T >
215 bool isInOpenClosed(
const IntervalType& interval,
const T& value )
217 return ( ( interval.getLower() < value ) && ( interval.getUpper() >= value ) );
230 template <
typename IntervalType,
typename T >
231 bool isInClosedOpen(
const IntervalType& interval,
const T& value )
233 return ( ( interval.getLower() <= value ) && ( interval.getUpper() > value ) );
236 template <
typename T >
240 m_interval.first = std::min( c.first, c.second );
241 m_interval.second = std::min( c.first, c.second );
244 template <
typename T >
246 m_interval( c.m_interval )
251 template <
typename T >
253 m_interval( std::min( l, u ), std::max( l, u ) )
258 template <
typename T >
264 template <
typename T >
270 template <
typename T >
273 return m_interval.first;
276 template <
typename T >
279 return m_interval.second;
282 template <
typename T >
285 return getUpper() - getLower();
288 template <
typename T >
291 return ( ( interval.
getLower() == getLower() ) && ( interval.
getUpper() == getUpper() ) );
294 template <
typename T >
297 return !operator==( interval );
300 #endif // WINTERVAL_H
const T & getLower() const
Get the lower value of the interval.
bool operator==(Type interval) const
Compare this interval with another one.
Basic class for encapsulating a std::pair to be interpreted as interval.
virtual ~WInterval()
Destructor.
boost::shared_ptr< const WInterval< T > > ConstSPtr
Convenience typedef for a boost::shared_ptr< const WInterval >.
bool operator!=(Type interval) const
Compare this interval with another one.
T getLength() const
The length of the interval.
WInterval(const StoreType &c)
Copy constructor to create a WInterval using a std::pair.
StoreType m_interval
The interval itself.
std::pair< T, T > StoreType
Type used to store the information.
const T & getUpper() const
Return the upper value of the interval.
WInterval< T > Type
My own type.
boost::shared_ptr< WInterval< T > > SPtr
Convenience typedef for a boost::shared_ptr< WInterval >.