33 #include "../WTypeTraits.h"
41 template<
typename T >
48 typedef std::shared_ptr< WInterval< T > >
SPtr;
53 typedef std::shared_ptr< const WInterval< T > >
ConstSPtr;
159 template <
typename T1,
typename T2 >
175 template <
typename IntervalType,
typename T >
176 bool isInClosed(
const IntervalType& interval,
const T& value )
178 return ( ( interval.getLower() <= value ) && ( interval.getUpper() >= value ) );
191 template <
typename IntervalType,
typename T >
192 bool isInOpen(
const IntervalType& interval,
const T& value )
194 return ( ( interval.getLower() < value ) && ( interval.getUpper() > value ) );
207 template <
typename IntervalType,
typename T >
208 bool isInOpenClosed(
const IntervalType& interval,
const T& value )
210 return ( ( interval.getLower() < value ) && ( interval.getUpper() >= value ) );
223 template <
typename IntervalType,
typename T >
224 bool isInClosedOpen(
const IntervalType& interval,
const T& value )
226 return ( ( interval.getLower() <= value ) && ( interval.getUpper() > value ) );
229 template <
typename T >
233 m_interval.first = std::min( c.first, c.second );
234 m_interval.second = std::min( c.first, c.second );
237 template <
typename T >
239 m_interval( std::min( l, u ), std::max( l, u ) )
244 template <
typename T >
250 template <
typename T >
256 template <
typename T >
259 return m_interval.first;
262 template <
typename T >
265 return m_interval.second;
268 template <
typename T >
271 return getUpper() - getLower();
274 template <
typename T >
277 return ( ( interval.
getLower() == getLower() ) && ( interval.
getUpper() == getUpper() ) );
280 template <
typename T >
283 return !operator==( interval );
Basic class for encapsulating a std::pair to be interpreted as interval.
std::shared_ptr< const WInterval< T > > ConstSPtr
Convenience typedef for a std::shared_ptr< const WInterval >.
WInterval(const StoreType &c)
Copy constructor to create a WInterval using a std::pair.
T getLength() const
The length of the interval.
bool operator==(Type interval) const
Compare this interval with another one.
WInterval(const T &l, const T &u)
Create a new interval instance using the given values.
const T & getUpper() const
Return the upper value of the interval.
bool operator!=(Type interval) const
Compare this interval with another one.
const T & getLower() const
Get the lower value of the interval.
virtual ~WInterval()
Destructor.
StoreType m_interval
The interval itself.
std::shared_ptr< WInterval< T > > SPtr
Convenience typedef for a std::shared_ptr< WInterval >.
WInterval< T > Type
My own type.
std::pair< T, T > StoreType
Type used to store the information.