stdex Additional custom or not Standard C++ covered algorithms

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
stdex::interval< T > Struct Template Reference

Numerical interval. More...

`#include <stdex/interval.hpp>`

## Public Member Functions
| interval () noexcept
| Constructs an invalid interval.
| interval (T x) noexcept
| Constructs a zero-size interval.
| interval (T _start, T _end) noexcept
| Constructs an interval.
T | size () const
| Returns interval size.
bool | empty () const
| Is interval empty?
void | invalidate ()
| Invalidates interval.
| operator bool () const
| Is interval valid?
bool | contains (T x) const
| Is value in interval?
interval | operator+ (const interval &other) const
| Adds two intervals by components.
interval | operator+ (const T x) const
| Moves interval towards the end by a number.
interval | operator+= (const T x)
| Moves interval towards the end by a number.
interval | operator++ ()
| Moves interval towards the end by one.
interval | operator++ (int)
| Moves interval towards the end by one.
interval | operator- (const interval &other) const
| Subtracts two intervals by components.
interval | operator- (const T x) const
| Moves interval towards the beginning by a number.
interval | operator-= (const T x)
| Moves interval towards the beginning by a number.
interval | operator-- ()
| Moves interval towards the beginning by one.
interval | operator-- (int)
| Moves interval towards the begginning by one.
bool | operator== (const interval &other) const
| Are intervals identical?
bool | operator!= (const interval &other) const
| Are intervals different?

## Public Attributes
T | start
| interval start
T | end
| interval end

## Detailed Description

template<class T>
struct stdex::interval< T >

Numerical interval.

## Constructor & Destructor Documentation

## ◆ interval() [1/2]

template<class T >

stdex::interval< T >::interval | ( | T | x | ) |
| inline noexcept

Constructs a zero-size interval.

Parameters

  [in] | x | Interval start and end value

## ◆ interval() [2/2]

template<class T >

stdex::interval< T >::interval | ( | T | _start,
|  | T | _end )
| inline noexcept

Constructs an interval.

Parameters

  [in] | _start | Interval start value
  [in] | _end | Interval end value

## Member Function Documentation

## ◆ contains()

template<class T >

bool stdex::interval< T >::contains | ( | T | x | ) | const
| inline

Is value in interval?

Parameters

  [in] | x | Value to test

Returns
  true if x is in [start, end) or false otherwise

## ◆ empty()

template<class T >

bool stdex::interval< T >::empty | ( |  | ) | const
| inline

Is interval empty?

Returns
  true if interval is empty or false otherwise

## ◆ operator bool()

template<class T >

stdex::interval< T >::operator bool | ( |  | ) | const
| inline

Is interval valid?

Returns
  true if interval is valid or false otherwise

## ◆ operator!=()

template<class T >

bool stdex::interval< T >::operator!= | ( | const interval< T > & | other | ) | const
| inline

Are intervals different?

Parameters

  [in] | other | Second interval to compare

Returns
  true if intervals are different or false otherwise

## ◆ operator+() [1/2]

template<class T >

interval stdex::interval< T >::operator+ | ( | const interval< T > & | other | ) | const
| inline

Adds two intervals by components.

Parameters

  [in] | other | Second interval

Returns
  Resulting interval

## ◆ operator+() [2/2]

template<class T >

interval stdex::interval< T >::operator+ | ( | const T | x | ) | const
| inline

Moves interval towards the end by a number.

Parameters

  [in] | x | Amount to move for

Returns
  Moved interval

## ◆ operator++() [1/2]

template<class T >

interval stdex::interval< T >::operator++ | ( |  | ) |
| inline

Moves interval towards the end by one.

Returns
  Moved interval

## ◆ operator++() [2/2]

template<class T >

interval stdex::interval< T >::operator++ | ( | int |  | ) |
| inline

Moves interval towards the end by one.

Returns
  Original interval

## ◆ operator+=()

template<class T >

interval stdex::interval< T >::operator+= | ( | const T | x | ) |
| inline

Moves interval towards the end by a number.

Parameters

  [in] | x | Amount to move for

Returns
  Resulting interval

## ◆ operator-() [1/2]

template<class T >

interval stdex::interval< T >::operator- | ( | const interval< T > & | other | ) | const
| inline

Subtracts two intervals by components.

Parameters

  [in] | other | Second interval

Returns
  Resulting interval

## ◆ operator-() [2/2]

template<class T >

interval stdex::interval< T >::operator- | ( | const T | x | ) | const
| inline

Moves interval towards the beginning by a number.

Parameters

  [in] | x | Amount to move for

Returns
  Moved interval

## ◆ operator--() [1/2]

template<class T >

interval stdex::interval< T >::operator-- | ( |  | ) |
| inline

Moves interval towards the beginning by one.

Returns
  Moved interval

## ◆ operator--() [2/2]

template<class T >

interval stdex::interval< T >::operator-- | ( | int |  | ) |
| inline

Moves interval towards the begginning by one.

Returns
  Original interval

## ◆ operator-=()

template<class T >

interval stdex::interval< T >::operator-= | ( | const T | x | ) |
| inline

Moves interval towards the beginning by a number.

Parameters

  [in] | x | Amount to move for

Returns
  Resulting interval

## ◆ operator==()

template<class T >

bool stdex::interval< T >::operator== | ( | const interval< T > & | other | ) | const
| inline

Are intervals identical?

Parameters

  [in] | other | Second interval to compare

Returns
  true if intervals are identical or false otherwise

## ◆ size()

template<class T >

T stdex::interval< T >::size | ( |  | ) | const
| inline

Returns interval size.

Returns
  Interval size or 0 if interval is invalid

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

- include/stdex/interval.hpp