32 #include <boost/shared_ptr.hpp>
35 #include "../WTypeTraits.h"
43 template<
typename T >
50 typedef boost::shared_ptr< WInterval< T > >
SPtr;
55 typedef boost::shared_ptr< const WInterval< T > >
ConstSPtr;
99 operator const StoreType& ()
const;
168 template <
typename T1,
typename T2 >
184 template <
typename IntervalType,
typename T >
185 bool isInClosed(
const IntervalType& interval,
const T& value )
187 return ( ( interval.getLower() <= value ) && ( interval.getUpper() >= value ) );
200 template <
typename IntervalType,
typename T >
201 bool isInOpen(
const IntervalType& interval,
const T& value )
203 return ( ( interval.getLower() < value ) && ( interval.getUpper() > value ) );
216 template <
typename IntervalType,
typename T >
217 bool isInOpenClosed(
const IntervalType& interval,
const T& value )
219 return ( ( interval.getLower() < value ) && ( interval.getUpper() >= value ) );
232 template <
typename IntervalType,
typename T >
233 bool isInClosedOpen(
const IntervalType& interval,
const T& value )
235 return ( ( interval.getLower() <= value ) && ( interval.getUpper() > value ) );
238 template <
typename T >
242 m_interval.first = std::min( c.first, c.second );
243 m_interval.second = std::min( c.first, c.second );
246 template <
typename T >
248 m_interval( c.m_interval )
253 template <
typename T >
255 m_interval(
std::min( l, u ),
std::max( l, u ) )
260 template <
typename T >
266 template <
typename T >
272 template <
typename T >
275 return m_interval.first;
278 template <
typename T >
281 return m_interval.second;
284 template <
typename T >
287 return getUpper() - getLower();
290 template <
typename T >
293 return ( ( interval.
getLower() == getLower() ) && ( interval.
getUpper() == getUpper() ) );
296 template <
typename T >
299 return !operator==( interval );
302 #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 >.