Viskores  1.0
Public Member Functions | Public Attributes | List of all members
viskores::Range Struct Reference

Represent a continuous scalar range of values. More...

#include <Range.h>

Public Member Functions

 Range ()
 Construct a range with a given minimum and maximum. More...
 
 Range (const Range &)=default
 
 Range (Range &&)=default
 
template<typename T1 , typename T2 >
 Range (const T1 &min, const T2 &max)
 
viskores::Rangeoperator= (const viskores::Range &src)=default
 
viskores::Rangeoperator= (viskores::Range &&src)=default
 
bool IsNonEmpty () const
 Determine if the range is valid (i.e. More...
 
template<typename T >
bool Contains (const T &value) const
 Determines if a value is within the range. More...
 
viskores::Float64 Length () const
 Returns the length of the range. More...
 
viskores::Float64 Center () const
 Returns the center of the range. More...
 
template<typename T >
void Include (const T &value)
 Expand range to include a value. More...
 
void Include (const viskores::Range &range)
 Expand range to include other range. More...
 
viskores::Range Union (const viskores::Range &otherRange) const
 Return the union of this and another range. More...
 
viskores::Range Intersection (const viskores::Range &otherRange) const
 Return the intersection of this and another range. More...
 
viskores::Range operator+ (const viskores::Range &otherRange) const
 Operator for union More...
 
bool operator== (const viskores::Range &otherRange) const
 
bool operator!= (const viskores::Range &otherRange) const
 

Public Attributes

viskores::Float64 Min
 The minumum value of the range (inclusive). More...
 
viskores::Float64 Max
 Tha maximum value of the range (inclusive). More...
 

Detailed Description

Represent a continuous scalar range of values.

viskores::Range is a helper class for representing a range of floating point values from a minimum value to a maximum value. This is specified simply enough with a Min and Max value.

Range also contains several helper functions for computing and maintaining the range.

Constructor & Destructor Documentation

◆ Range() [1/4]

viskores::Range::Range ( )
inline

Construct a range with a given minimum and maximum.

If no minimum or maximum is given, the range will be empty.

◆ Range() [2/4]

viskores::Range::Range ( const Range )
default

◆ Range() [3/4]

viskores::Range::Range ( Range &&  )
default

◆ Range() [4/4]

template<typename T1 , typename T2 >
viskores::Range::Range ( const T1 &  min,
const T2 &  max 
)
inline

Member Function Documentation

◆ Center()

viskores::Float64 viskores::Range::Center ( ) const
inline

Returns the center of the range.

Center computes the middle value of the range. If the range is empty, NaN is returned.

◆ Contains()

template<typename T >
bool viskores::Range::Contains ( const T &  value) const
inline

Determines if a value is within the range.

Contains returns true if the give value is within the range, false otherwise. Contains treats the min and max as inclusive. That is, if the value is exactly the min or max, true is returned.

◆ Include() [1/2]

template<typename T >
void viskores::Range::Include ( const T &  value)
inline

Expand range to include a value.

This version of Include expands the range just enough to include the given value. If the range already includes this value, then nothing is done.

◆ Include() [2/2]

void viskores::Range::Include ( const viskores::Range range)
inline

Expand range to include other range.

This version of Include expands this range just enough to include that of another range. Essentially it is the union of the two ranges.

◆ Intersection()

viskores::Range viskores::Range::Intersection ( const viskores::Range otherRange) const
inline

Return the intersection of this and another range.

◆ IsNonEmpty()

bool viskores::Range::IsNonEmpty ( ) const
inline

Determine if the range is valid (i.e.

has at least one valid point).

IsNonEmpty return true if the range contains some valid values between Min and Max. If Max is less than Min, then no values satisfy the range and IsNonEmpty returns false. Otherwise, return true.

IsNonEmpty assumes Min and Max are inclusive. That is, if they are equal then true is returned.

◆ Length()

viskores::Float64 viskores::Range::Length ( ) const
inline

Returns the length of the range.

Length computes the distance between the min and max. If the range is empty, 0 is returned.

◆ operator!=()

bool viskores::Range::operator!= ( const viskores::Range otherRange) const
inline

◆ operator+()

viskores::Range viskores::Range::operator+ ( const viskores::Range otherRange) const
inline

Operator for union

◆ operator=() [1/2]

viskores::Range& viskores::Range::operator= ( const viskores::Range src)
default

◆ operator=() [2/2]

viskores::Range& viskores::Range::operator= ( viskores::Range &&  src)
default

◆ operator==()

bool viskores::Range::operator== ( const viskores::Range otherRange) const
inline

◆ Union()

viskores::Range viskores::Range::Union ( const viskores::Range otherRange) const
inline

Return the union of this and another range.

This is a nondestructive form of Include.

Member Data Documentation

◆ Max

viskores::Float64 viskores::Range::Max

Tha maximum value of the range (inclusive).

◆ Min

viskores::Float64 viskores::Range::Min

The minumum value of the range (inclusive).


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