Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template interval

boost::itl::interval — A class template for intervals.

Synopsis

template<class DomainT , 
         ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT)> 
class interval {
public:
  // types
  typedef interval< DomainT, Compare >              type;           
  typedef DomainT                                   domain_type;      // The domain type of the interval. 
  typedef DomainT                                   codomain_type;    // The codomaintype is the same as domain_type. 
  typedef DomainT                                   element_type;     // The element type of the interval. 
  typedef type                                      segment_type;     // The segment type is the interval's type. 
  typedef type                                      interval_type;    // The interval type is the interval's type. 
  typedef DomainT                                   key_type;       
  typedef DomainT                                   data_type;      
  typedef DomainT                                   value_type;     
  typedef domain_compare                            key_compare;    
  typedef itl::difference< DomainT >::type          difference_type;  // The difference type of an interval which is sometimes different form the domain_type. 
  typedef itl::size< DomainT >::type                size_type;        // The size type of an interval which is mostly std::size_t. 
  typedef boost::call_traits< DomainT >::param_type DomainP;        

  // construct/copy/destruct
  interval();
  interval(const DomainT &);
  interval(const DomainT &, const DomainT &, 
           itl::bound_type = itl::closed_bounded);

  // public member functions
  typedef ITL_COMPARE_DOMAIN(Compare, DomainT) ;
  bool empty() const;
  void clear() ;
  bool contains(const DomainT &) const;
  bool contains(const interval &) const;
  bool contained_in(const interval &) const;
  bool free_contains(const interval &) const;
  bool proper_contains(const interval &) const;
  bool is_disjoint(const interval &) const;
  bool intersects(const interval &) const;
  size_type cardinality() const;
  difference_type length() const;
  size_type size() const;
  DomainT lower() const;
  DomainT upper() const;
  DomainT first() const;
  DomainT last() const;
  bound_type boundtype() const;
  interval & extend(const interval &) ;
  interval & left_extend(const interval &) ;
  interval & right_extend(const interval &) ;
  interval & left_set(const interval &) ;
  interval & right_set(const interval &) ;
  interval span(const interval &) const;
  interval & left_subtract(const interval &) ;
  interval & right_subtract(const interval &) ;
  interval & operator&=(const interval &) ;
  const std::string as_string() const;
  bool is(bound_type) const;
  bool is_left(bound_type) const;
  bool is_right(bound_type) const;
  bool touches(const interval &) const;
  bool exclusive_less(const interval &) const;
  bool distant_less(const interval &) const;
  interval & set(const DomainT &, const DomainT &, bound_type) ;
  interval & as(bound_type) ;
  bool lower_less(const interval &) const;
  bool upper_less(const interval &) const;
  bool lower_less_equal(const interval &) const;
  bool upper_less_equal(const interval &) const;
  bool lower_equal(const interval &) const;
  bool upper_equal(const interval &) const;

  // public static functions
  static interval closed(const DomainT &, const DomainT &) ;
  static interval rightopen(const DomainT &, const DomainT &) ;
  static interval leftopen(const DomainT &, const DomainT &) ;
  static interval open(const DomainT &, const DomainT &) ;
  static interval whole() ;
  static bool domain_less(DomainP, DomainP) ;
  static bool domain_less_equal(DomainP, DomainP) ;
  static bool domain_equal(DomainP, DomainP) ;

  // private member functions
  void set_lwb(DomainT) ;
  void set_upb(DomainT) ;
  void set_lwb_type(bound_type) ;
  void set_upb_type(bound_type) ;
  bound_type succession_bounds() const;
  void set_lwb(const BoundT &) ;
  void set_upb(const BoundT &) ;
  BoundT lwb_min(const interval &) const;
  BoundT lwb_max(const interval &) const;
  BoundT upb_min(const interval &) const;
  BoundT upb_max(const interval &) const;
  BoundT lwb_right_of(const interval &) const;
  BoundT upb_left_of(const interval &) const;

  // private static functions
  static bound_type span(bound_type, bound_type) ;
};

Description

interval public construct/copy/destruct

  1. interval();

    Default constructor; yields an empty interval [1,0]

  2. interval(const DomainT & val);

    Constructor for a closed singleton interval [val,val]

  3. interval(const DomainT & low, const DomainT & up, 
             itl::bound_type bounds = itl::closed_bounded);

    Interval from low to up with bounds bounds

interval public member functions

  1. typedef ITL_COMPARE_DOMAIN(Compare, DomainT) ;
  2. bool empty() const;

    Is the interval empty?

  3. void clear() ;

    Set the interval empty

  4. bool contains(const DomainT & x) const;

    Does the interval contain x?

  5. bool contains(const interval & sub) const;

    *this is superset of sub

  6. bool contained_in(const interval & super) const;

    *this is subset of super

  7. bool free_contains(const interval & sub) const;

    sub is proper subset of *this and does not touch the borders of *this

  8. bool proper_contains(const interval & sub) const;

    sub is proper subset of *this

  9. bool is_disjoint(const interval & x2) const;

    *this and x2 are disjoint; their intersection is empty

  10. bool intersects(const interval & x2) const;

    *this and x2 have a non empty intersection

  11. size_type cardinality() const;

    Cardinality of the interval: The number of elements

  12. difference_type length() const;

    Arithmetic size of the interval

  13. size_type size() const;

    Size of the interval

  14. DomainT lower() const;

    Lower bound of the interval

  15. DomainT upper() const;

    Upper bound of the interval

  16. DomainT first() const;

    First (smallest) element of the interval

  17. DomainT last() const;

    Last (largest) element of the interval

  18. bound_type boundtype() const;

    Typ of interval bounds

  19. interval & extend(const interval & x2) ;

    Extend *this to x2 yielding an interval from the minimum of lower bounds to the maximum of upper bounds

  20. interval & left_extend(const interval & left_extension) ;

    Extend *this interval to the minimum of the lower bounds of this and left_extension.

  21. interval & right_extend(const interval & right_extension) ;

    Extend *this interval to the maximum of the upper bounds of this and right_extension.

  22. interval & left_set(const interval & left) ;

    Set the lower bound and bound type according to interval left.

  23. interval & right_set(const interval & right) ;

    Set the upper bound and bound type according to interval right.

  24. interval span(const interval & rhs) const;

    Interval spanning from lower bound of *this interval to the upper bound of rhs. Bordertypes according to the lower bound of *this and the upper bound of rhs.

  25. interval & left_subtract(const interval & left_minuend) ;

    subtract left_minuend from *this interval on it's left side.

    *this = *this - left_minuend; //on the left.
    ...      d) : *this
    ... c)      : left_minuend
         [c  d) : *this
    

  26. interval & right_subtract(const interval & right_minuend) ;

    subtract right_minuend from *this interval on it's right side.

    *this = *this - right_minuend; //on the right side.
    [a      ...  : *this
         [b ...  : right_minuend
    [a  b)       : *this
    

  27. interval & operator&=(const interval & sectant) ;

    Intersection with the interval x2; assign result to isec

  28. const std::string as_string() const;

    Object as string

  29. bool is(bound_type bounded) const;

    What type is the interval?

    interval.is(closed_bounded); //[x, y] a closed interval
    interval.is(right_open);     //[x, y) a right-open interval (also left-closed interval)
    interval.is(left_open);      //(x, y] a left-open interval  (also right-closed interval)
    interval.is(open_bounded);   //(x, y) an open interval
    

  30. bool is_left(bound_type bounded) const;

    What bound type is the left interval border?

    interval.is_left(closed_bounded); //[x, y] or [x, y)
    interval.is_left(open_bounded);   //(x, y] or (x, y)
    

  31. bool is_right(bound_type bounded) const;

    What bound type is the right interval border?

    interval.is_right(closed_bounded); //[x, y] or (x, y]
    interval.is_right(open_bounded);   //[x, y) or (x, y)
    

  32. bool touches(const interval & x2) const;

    There is no gap between *this and x2 but they have no element in common

  33. bool exclusive_less(const interval & x2) const;

    Maximal element of *this is less than the minimal element of x2

  34. bool distant_less(const interval & x2) const;

    Maximal element of *this is less than the minimal element of x2 and there is at least one element in between.

  35. interval & set(const DomainT & low, const DomainT & up, bound_type bounds) ;

    Set *this interval to from low to up with boundtype bounds

  36. interval & as(bound_type bounded) ;

    Transforms the interval to the bound-type bounded without changing it's content. Requires Integral<domain_type>.

    interval.as(closed_bounded).is(closed_bounded) &&
    interval.as(right_open).is(right_open) &&
    interval.as(left_open).is(left_open) &&
    interval.as(open_bounded).is(open_bounded)
    

  37. bool lower_less(const interval & x2) const;

    First element of *this is less than first element of x2

  38. bool upper_less(const interval & x2) const;

    Last element of *this is less than last element of x2

  39. bool lower_less_equal(const interval & x2) const;

    First element of *this is less than or equal to the first element of x2

  40. bool upper_less_equal(const interval & x2) const;

    Last element of *this is less than or equal to the last element of x2

  41. bool lower_equal(const interval & x2) const;

    First element of *this is equal to the first element of x2

  42. bool upper_equal(const interval & x2) const;

    Last element of *this is equal to the last element of x2

interval public static functions

  1. static interval closed(const DomainT & low, const DomainT & up) ;

    Closed interval [low,up]

  2. static interval rightopen(const DomainT & low, const DomainT & up) ;

    Rightopen interval [low,up)

  3. static interval leftopen(const DomainT & low, const DomainT & up) ;

    Leftopen interval (low,up]

  4. static interval open(const DomainT & low, const DomainT & up) ;

    Open interval (low,up)

  5. static interval whole() ;

    An interval that covers the complete range of it's domain_type

  6. static bool domain_less(DomainP left, DomainP right) ;

    Less compare of interval elements.

  7. static bool domain_less_equal(DomainP left, DomainP right) ;

    Less or equal compare of interval elements.

  8. static bool domain_equal(DomainP left, DomainP right) ;

    Equality compare of interval elements.

interval private member functions

  1. void set_lwb(DomainT lw) ;
  2. void set_upb(DomainT up) ;
  3. void set_lwb_type(bound_type bounds) ;
  4. void set_upb_type(bound_type bounds) ;
  5. bound_type succession_bounds() const;
  6. void set_lwb(const BoundT & lw) ;
  7. void set_upb(const BoundT & up) ;
  8. BoundT lwb_min(const interval & x2) const;
  9. BoundT lwb_max(const interval & x2) const;
  10. BoundT upb_min(const interval & x2) const;
  11. BoundT upb_max(const interval & x2) const;
  12. BoundT lwb_right_of(const interval & x2) const;
  13. BoundT upb_left_of(const interval & x2) const;

interval private static functions

  1. static bound_type span(bound_type left, bound_type right) ;

PrevUpHomeNext