User Manual, Developers Guide and API Documentation

wns::Interval< T > Class Template Reference

Interval representation. More...

#include <Interval.hpp>

Inheritance diagram for wns::Interval< T >:

Inheritance graph
[legend]
Collaboration diagram for wns::Interval< T >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef T ValueType

Public Member Functions

bool contains (const Interval &x) const
 Check if the interval x is totally contained in *this.
bool contains (const ValueType &x) const
 Check if value x is in the interval.
Interval intersect (const Interval &x) const
 Create a new interval by intersecting *this with x.
 Interval ()
 Return empty interval.
bool isAbove (const Interval &x) const
 Check if this interval is above interval x.
bool isAbove (const ValueType &x) const
 Check if the value x is smaller than all values of the interval.
bool isBelow (const Interval &x) const
 Check if this interval is below interval x.
bool isBelow (const ValueType &x) const
 Check if the value x is greater than all values of the interval.
bool isEmpty () const
 Check if this interval is empty.
Interval join (const Interval &x) const
 Create a new interval by joining *this with x.
bool joinableWith (const Interval &x) const
 Check if this interval can be joined with interval x.
ValueType max () const
 Return maximal value that is contained in this interval.
ValueType min () const
 Return minimal value that is contained in this interval.
bool operator!= (const Interval &x) const
bool operator== (const Interval &x) const
 Check if two intervals are equal.
bool overlaps (const Interval &x) const
 Check if this interval overlaps with the interval x.

Static Public Member Functions

static BetweenEndpoint Between (const ValueType &a)
 Create open interval.
static Interval CreateFrom (const pyconfig::View &config)
 Create interval from pyconfig::View.
static Interval EmptyInterval ()
 Return empty interval.
static FromEndpoint From (const ValueType &a)
 Create closed interval.
static FromInclExclEndpoint FromExcluding (const ValueType &a)
 Create half-open (or open) interval.
static FromInclExclEndpoint FromIncluding (const ValueType &a)
 Create half-open (or closed) interval.

Private Member Functions

 Interval (const Endpoint &a, const Endpoint &b)

Private Attributes

Endpoint a
Endpoint b

Friends

class Endpoint

Classes

class  BetweenEndpoint
 Endpoint for syntax Between ... And. More...
class  Endpoint
 Open or closed endpoint of an interval. More...
class  FromEndpoint
 Endpoint for syntax From ... To. More...
class  FromInclExclEndpoint
 Endpoint for syntax FromIncluding/FromExcluding ... ToIncluding/ToExcluding. More...


Detailed Description

template<typename T>
class wns::Interval< T >

Parameters:
T Interval of this type.
This template class represents Intervals in the set T. Please be aware that in mathematics intervals are usually subsets of R, but computers - being finite - don't have reals. So you can create Intervals of integer and floating point types with this class.

Intervals are created quite easily. Examples:

Note that the constructor is private; use the static constructing functions instead.

Interval supports all combinations of open and closed intervals: (a,b), (a,b], [a,b) and [a,b].

Intervals are immutable.

Definition at line 76 of file Interval.hpp.


Member Typedef Documentation

template<typename T>
typedef T wns::Interval< T >::ValueType

Definition at line 80 of file Interval.hpp.


Constructor & Destructor Documentation

template<typename T>
wns::Interval< T >::Interval (  )  [inline]

Definition at line 255 of file Interval.hpp.

template<typename T>
wns::Interval< T >::Interval ( const Endpoint a,
const Endpoint b 
) [inline, private]

Definition at line 442 of file Interval.hpp.


Member Function Documentation

template<typename T>
static BetweenEndpoint wns::Interval< T >::Between ( const ValueType a  )  [inline, static]

Parameters:
a (in) lower bound.
Use like this: Between(a).And(b). This creates the interval (a,b).

Definition at line 203 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::contains ( const Interval< T > &  x  )  const [inline]

Parameters:
x Is that interval contained?

Definition at line 366 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::contains ( const ValueType x  )  const [inline]

Parameters:
x Is that value contained?

Definition at line 356 of file Interval.hpp.

template<typename T>
static Interval wns::Interval< T >::CreateFrom ( const pyconfig::View config  )  [inline, static]

Parameters:
config (in) Configuration specifying the endpoints.

Definition at line 183 of file Interval.hpp.

template<typename T>
static Interval wns::Interval< T >::EmptyInterval (  )  [inline, static]

Definition at line 248 of file Interval.hpp.

template<typename T>
static FromEndpoint wns::Interval< T >::From ( const ValueType a  )  [inline, static]

Parameters:
a (in) lower bound.
Use like this: From(a).To(b). This creates the interval [a,b].

Definition at line 215 of file Interval.hpp.

template<typename T>
static FromInclExclEndpoint wns::Interval< T >::FromExcluding ( const ValueType a  )  [inline, static]

Parameters:
a (in) lower bound.
Use like this: FromExcluding(a).ToIncluding(b). This creates (a,b]. (You could also use FromExcluding(a).ToExcluding(b) but Between(a).And(b) is shorter.)

Definition at line 241 of file Interval.hpp.

template<typename T>
static FromInclExclEndpoint wns::Interval< T >::FromIncluding ( const ValueType a  )  [inline, static]

Parameters:
a (in) lower bound.
Use like this: FromIncluding(a).ToExcluding(b). This creates [a,b). (You could also use FromIncluding(a).ToIncluding(b) but From(a).To(b) is shorter.)

Definition at line 228 of file Interval.hpp.

template<typename T>
Interval wns::Interval< T >::intersect ( const Interval< T > &  x  )  const [inline]

Parameters:
x Intersect with that.
Returns:
intersection Interval.
Return a new Interval that is the intersection of *this and x. The returned Interval may be empty.

Definition at line 433 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::isAbove ( const Interval< T > &  x  )  const [inline]

Parameters:
x Is that smaller?
This returns true, if *this contains values larger than the values of x.

Definition at line 314 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::isAbove ( const ValueType x  )  const [inline]

Parameters:
x Is that value smaller?

Definition at line 301 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::isBelow ( const Interval< T > &  x  )  const [inline]

Parameters:
x Is that larger?
This returns true, if *this contains values smaller than the values of x.

Definition at line 291 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::isBelow ( const ValueType x  )  const [inline]

Parameters:
x Is that value greater?

Definition at line 278 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::isEmpty (  )  const [inline]

Returns:
true if empty.

Definition at line 324 of file Interval.hpp.

template<typename T>
Interval wns::Interval< T >::join ( const Interval< T > &  x  )  const [inline]

Parameters:
x Join with that.
Returns:
joined Interval.
Return a new Interval that ranges from the smallest Endpoint to the largest Endpoint. *this and x need to be joinable.

See also:
joinable(const Interval&)

Definition at line 411 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::joinableWith ( const Interval< T > &  x  )  const [inline]

Parameters:
x Can we be joined with that?
Intervals are joinable, if a new Interval can be created from them, that contains all values from the original intervals. Thus they must be at least directly adjacent.

Definition at line 392 of file Interval.hpp.

template<typename T>
ValueType wns::Interval< T >::max (  )  const [inline]

Returns:
maximal value.

Definition at line 345 of file Interval.hpp.

template<typename T>
ValueType wns::Interval< T >::min (  )  const [inline]

Returns:
minimal value.

Definition at line 334 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::operator!= ( const Interval< T > &  x  )  const [inline]

Definition at line 268 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::operator== ( const Interval< T > &  x  )  const [inline]

Definition at line 263 of file Interval.hpp.

template<typename T>
bool wns::Interval< T >::overlaps ( const Interval< T > &  x  )  const [inline]

Parameters:
x Are we overlapping with that?

Definition at line 376 of file Interval.hpp.


Friends And Related Function Documentation

template<typename T>
friend class Endpoint [friend]

Definition at line 78 of file Interval.hpp.


Member Data Documentation

template<typename T>
Endpoint wns::Interval< T >::a [private]

Definition at line 446 of file Interval.hpp.

template<typename T>
Endpoint wns::Interval< T >::b [private]

Definition at line 447 of file Interval.hpp.


The documentation for this class was generated from the following file:

Generated on Sat May 26 03:32:50 2012 for openWNS by  doxygen 1.5.5