class ov::Interval

Overview

Interval arithmetic. More…

#include <interval.hpp>

class Interval
{
public:
    // typedefs

    typedef std::int64_t value_type;
    typedef std::uint64_t size_type;

    // fields

    static constexpr value_type s_max {std::numeric_limits<value_type>::max()};

    // construction

    Interval();
    Interval(const Interval& interval);
    Interval(value_type min_val, value_type max_val);
    Interval(value_type val);

    // methods

    Interval& operator = (const Interval& interval);
    size_type size() const;
    bool empty() const;
    value_type get_min_val() const;
    void set_min_val(value_type val);
    value_type get_max_val() const;
    void set_max_val(value_type val);
    bool has_upper_bound() const;
    bool operator == (const Interval& interval) const;
    bool operator != (const Interval& interval) const;
    Interval operator + (const Interval& interval) const;
    Interval& operator += (const Interval& interval);
    Interval operator - (const Interval& interval) const;
    Interval& operator -= (const Interval& interval);
    Interval operator\* (const Interval& interval) const;
    Interval& operator\*= (const Interval& interval);
    Interval operator & (const Interval& interval) const;
    Interval& operator &= (const Interval& interval);
    bool contains(value_type value) const;
    bool contains(const Interval& interval) const;
};

Detailed Documentation

Interval arithmetic.

Fields

static constexpr value_type s_max {std::numeric_limits<value_type>::max()}

The value used for no upper bound.

Construction

Interval()

Interval of everything.

Interval(const Interval& interval)

Copy constructor.

Interval(value_type min_val, value_type max_val)

Closed interval {x|min_val <= x <= max_val}.

Interval(value_type val)

Single-valued interval; just contains val.

Methods

size_type size() const

The number of elements in the interval. Zero if max < min.

bool empty() const

Returns true if the interval has no elements.

value_type get_min_val() const

the inclusive lower bound of the interval

void set_min_val(value_type val)

Set the inclusive lower bound of the interval.

value_type get_max_val() const

the inclusive upper bound of the interval

void set_max_val(value_type val)

Set the inclusive upper bound of the interval.

bool has_upper_bound() const

True if the upper bound is finite.

bool operator == (const Interval& interval) const

True if min and max bounds match.

Interval operator + (const Interval& interval) const

The interval whose elements are a sum of an element from each interval.

Interval& operator += (const Interval& interval)

Extend this interval to sums of elements in this interval and interval.

Interval operator - (const Interval& interval) const

The interval whose elements are a difference of an element from each interval.

Interval& operator -= (const Interval& interval)

Extend this interval to differences of elements in this interval and interval.

Interval operator\* (const Interval& interval) const

The smallest interval whose elements are a product of an element from each interval.

Interval& operator\*= (const Interval& interval)

Extend this interval to products of elements in this interval and interval.

Interval operator & (const Interval& interval) const

The interval that is the intersection of this interval and interval.

Interval& operator &= (const Interval& interval)

Change this interval to only include elements also in interval.

bool contains(value_type value) const

True if this interval includes value.

bool contains(const Interval& interval) const

True if this interval includes all the values in interval.