yat  0.12.3pre
Public Types | Public Member Functions | Related Functions | List of all members
theplu::yat::utility::Segment< T, Compare > Class Template Reference

a class for a Segment or Interval More...

#include <yat/utility/Segment.h>

Public Types

typedef T value_type
 

Public Member Functions

 Segment (void)
 default constructor
 
 Segment (const T &begin, const T &end)
 Constructor. More...
 
T & begin (void)
 
const T & begin (void) const
 
T & end (void)
 
const T & end (void) const
 

Related Functions

(Note that these are not member functions.)

template<typename T , class Compare >
bool compare (const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
 
template<typename T , class Compare >
int compare_3way (const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
 
template<typename T , class Compare >
int compare_3way (const T &element, const Segment< T, Compare > &segment)
 
template<typename T , class Compare >
Segment< T, Compare > intersection (const Segment< T, Compare > &a, const Segment< T, Compare > &b)
 

Detailed Description

template<typename T, class Compare = std::less<T>>
class theplu::yat::utility::Segment< T, Compare >

a class for a Segment or Interval

A Segment is defined by its begin and end. The end is not included in the Segment, i.e., you could write the Segment as [begin, end). Type T must be comparable, optionally with a comparator Compare, which should implement Strict Weak Ordering..

Since
new in yat 0.7

Member Typedef Documentation

template<typename T, class Compare = std::less<T>>
typedef T theplu::yat::utility::Segment< T, Compare >::value_type

type the Segment holds

Constructor & Destructor Documentation

template<typename T, class Compare = std::less<T>>
theplu::yat::utility::Segment< T, Compare >::Segment ( const T &  begin,
const T &  end 
)
inline

Constructor.

Creates a segment [begin, end)

Member Function Documentation

template<typename T, class Compare = std::less<T>>
T& theplu::yat::utility::Segment< T, Compare >::begin ( void  )
inline
Returns
reference to first element in Segment
template<typename T, class Compare = std::less<T>>
const T& theplu::yat::utility::Segment< T, Compare >::begin ( void  ) const
inline
Returns
const reference to first element in Segment
template<typename T, class Compare = std::less<T>>
T& theplu::yat::utility::Segment< T, Compare >::end ( void  )
inline
Returns
reference to first element greater than Segment
template<typename T, class Compare = std::less<T>>
const T& theplu::yat::utility::Segment< T, Compare >::end ( void  ) const
inline
Returns
const reference to first element greater than Segment

Friends And Related Function Documentation

template<typename T , class Compare >
bool compare ( const Segment< T, Compare > &  lhs,
const Segment< T, Compare > &  rhs 
)
related

This function takes two Segment and compare them with comparator Compare. If all elements in lhs is less than all elements in rhs, true is returned. In other words, false is returned if rhs.begin() is less than lhs.end().

The exception is if both lhs and rhs are empty Segment (i.e. begin equals end) and their begins and ends are equal, in which case false is returned. This exception implies that compare(x,x) always returns false.

Since
new in yat 0.7
template<typename T , class Compare >
int compare_3way ( const Segment< T, Compare > &  lhs,
const Segment< T, Compare > &  rhs 
)
related
Returns
-1 if compare(lhs, rhs) is true, +1 if compare(rhs, lhs) is true, and 0 otherwise
See Also
compare(const Segment<T, Compare>&, const Segment<T, Compare>&)
Since
new in yat 0.7
template<typename T , class Compare >
int compare_3way ( const T &  element,
const Segment< T, Compare > &  segment 
)
related
Returns
-1 if element is less than all elements in segment, 0 if element overlaps with segment, and 1 otherwise.
Since
new in yat 0.7
template<typename T , class Compare >
Segment< T, Compare > intersection ( const Segment< T, Compare > &  a,
const Segment< T, Compare > &  b 
)
related
Returns
intersection of a and b. If a and b do not overlap an empty Section is returned (begin==end), but the exact value of begin is undefined.
Since
new in yat 0.7

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

Generated on Mon Jun 1 2015 12:29:53 for yat by  doxygen 1.8.5