Home | Libraries | People | FAQ | More |
boost::itl::interval — A class template for intervals.
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) ; };
interval
public member functionstypedef ITL_COMPARE_DOMAIN(Compare, DomainT) ;
bool empty() const;
Is the interval empty?
void clear() ;
Set the interval empty
bool contains(const DomainT & x) const;
Does the interval contain x
?
bool contains(const interval & sub) const;
*this
is superset of sub
bool contained_in(const interval & super) const;
*this
is subset of super
bool free_contains(const interval & sub) const;
sub
is proper subset of *this
and does not touch the borders of *this
bool proper_contains(const interval & sub) const;
sub
is proper subset of *this
bool is_disjoint(const interval & x2) const;
*this
and x2
are disjoint; their intersection is empty
bool intersects(const interval & x2) const;
*this
and x2
have a non empty intersection
size_type cardinality() const;
Cardinality of the interval: The number of elements
difference_type length() const;
Arithmetic size of the interval
size_type size() const;
Size of the interval
DomainT lower() const;
Lower bound of the interval
DomainT upper() const;
Upper bound of the interval
DomainT first() const;
First (smallest) element of the interval
DomainT last() const;
Last (largest) element of the interval
bound_type boundtype() const;
Typ of interval bounds
interval & extend(const interval & x2) ;
Extend *this
to x2
yielding an interval from the minimum of lower bounds to the maximum of upper bounds
interval & left_extend(const interval & left_extension) ;
Extend *this
interval to the minimum of the lower bounds of this
and left_extension
.
interval & right_extend(const interval & right_extension) ;
Extend *this
interval to the maximum of the upper bounds of this
and right_extension
.
interval & left_set(const interval & left) ;
Set the lower bound and bound type according to interval left
.
interval & right_set(const interval & right) ;
Set the upper bound and bound type according to interval right
.
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
.
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
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
interval & operator&=(const interval & sectant) ;
Intersection with the interval x2
; assign result to isec
const std::string as_string() const;
Object as string
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
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)
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)
bool touches(const interval & x2) const;
There is no gap between *this
and x2
but they have no element in common
bool exclusive_less(const interval & x2) const;
Maximal element of *this
is less than the minimal element of x2
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.
interval & set(const DomainT & low, const DomainT & up, bound_type bounds) ;
Set *this
interval to from low
to up
with boundtype bounds
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)
bool lower_less(const interval & x2) const;
First element of *this
is less than first element of x2
bool upper_less(const interval & x2) const;
Last element of *this
is less than last element of x2
bool lower_less_equal(const interval & x2) const;
First element of *this
is less than or equal to the first element of x2
bool upper_less_equal(const interval & x2) const;
Last element of *this
is less than or equal to the last element of x2
bool lower_equal(const interval & x2) const;
First element of *this
is equal to the first element of x2
bool upper_equal(const interval & x2) const;
Last element of *this
is equal to the last element of x2
interval
public static functionsstatic interval closed(const DomainT & low, const DomainT & up) ;
Closed interval [low,up]
static interval rightopen(const DomainT & low, const DomainT & up) ;
Rightopen interval [low,up)
static interval leftopen(const DomainT & low, const DomainT & up) ;
Leftopen interval (low,up]
static interval open(const DomainT & low, const DomainT & up) ;
Open interval (low,up)
static interval whole() ;
An interval that covers the complete range of it's domain_type
static bool domain_less(DomainP left, DomainP right) ;
Less compare of interval elements.
static bool domain_less_equal(DomainP left, DomainP right) ;
Less or equal compare of interval elements.
static bool domain_equal(DomainP left, DomainP right) ;
Equality compare of interval elements.
interval
private member functionsvoid set_lwb(DomainT lw) ;
void set_upb(DomainT up) ;
void set_lwb_type(bound_type bounds) ;
void set_upb_type(bound_type bounds) ;
bound_type succession_bounds() const;
void set_lwb(const BoundT & lw) ;
void set_upb(const BoundT & up) ;
BoundT lwb_min(const interval & x2) const;
BoundT lwb_max(const interval & x2) const;
BoundT upb_min(const interval & x2) const;
BoundT upb_max(const interval & x2) const;
BoundT lwb_right_of(const interval & x2) const;
BoundT upb_left_of(const interval & x2) const;