array
C++ library for multi-dimensional arrays
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
interval< Min_, Extent_ > Class Template Reference

#include <array.h>

Inheritance diagram for interval< Min_, Extent_ >:
dim< Min_, Extent_, Stride_ >

Public Member Functions

NDARRAY_HOST_DEVICE interval (index_t min, index_t extent)
 
NDARRAY_HOST_DEVICE interval (index_t min)
 
NDARRAY_HOST_DEVICE interval (const interval &)=default
 
NDARRAY_HOST_DEVICE interval (interval &&)=default
 
NDARRAY_HOST_DEVICE intervaloperator= (const interval &)=default
 
NDARRAY_HOST_DEVICE intervaloperator= (interval &&)=default
 
template<index_t CopyMin, index_t CopyExtent, class = internal::disable_if_not_equal<Min, CopyMin>, class = internal::disable_if_not_equal<Extent, CopyExtent>>
NDARRAY_HOST_DEVICE interval (const interval< CopyMin, CopyExtent > &other)
 
template<index_t CopyMin, index_t CopyExtent, class = internal::disable_if_not_equal<Min, CopyMin>, class = internal::disable_if_not_equal<Extent, CopyExtent>>
NDARRAY_HOST_DEVICE intervaloperator= (const interval< CopyMin, CopyExtent > &other)
 
NDARRAY_INLINE NDARRAY_HOST_DEVICE index_t min () const
 
NDARRAY_INLINE NDARRAY_HOST_DEVICE void set_min (index_t min)
 
NDARRAY_INLINE NDARRAY_HOST_DEVICE index_t extent () const
 
NDARRAY_INLINE NDARRAY_HOST_DEVICE index_t size () const
 
NDARRAY_INLINE NDARRAY_HOST_DEVICE void set_extent (index_t extent)
 
NDARRAY_INLINE NDARRAY_HOST_DEVICE index_t max () const
 
NDARRAY_INLINE NDARRAY_HOST_DEVICE void set_max (index_t max)
 
NDARRAY_INLINE NDARRAY_HOST_DEVICE bool is_in_range (index_t at) const
 
template<index_t OtherMin, index_t OtherExtent>
NDARRAY_INLINE NDARRAY_HOST_DEVICE bool is_in_range (const interval< OtherMin, OtherExtent > &at) const
 
template<index_t OtherMin, index_t OtherExtent, index_t OtherStride>
NDARRAY_INLINE NDARRAY_HOST_DEVICE bool is_in_range (const dim< OtherMin, OtherExtent, OtherStride > &at) const
 
NDARRAY_HOST_DEVICE index_iterator begin () const
 
NDARRAY_HOST_DEVICE index_iterator end () const
 
template<index_t OtherMin, index_t OtherExtent>
NDARRAY_HOST_DEVICE bool operator== (const interval< OtherMin, OtherExtent > &other) const
 
template<index_t OtherMin, index_t OtherExtent>
NDARRAY_HOST_DEVICE bool operator!= (const interval< OtherMin, OtherExtent > &other) const
 

Static Public Attributes

static constexpr index_t Min = Min_
 
static constexpr index_t Extent = Extent_
 
static constexpr index_t Max = internal::static_sub(internal::static_add(Min, Extent), 1)
 

Protected Attributes

internal::constexpr_index< Min_ > min_
 
internal::constexpr_index< Extent_ > extent_
 

Detailed Description

template<index_t Min_ = dynamic, index_t Extent_ = dynamic>
class nda::interval< Min_, Extent_ >

Describes a half-open interval of indices. The template parameters enable providing compile time constants for the min and extent of the interval. The values in the interval [min, min + extent) are considered in bounds.

interval<> a is said to be 'compatible with' another interval<Min, Extent> b if a.min() is compatible with Min and a.extent() is compatible with Extent.

Examples:

Constructor & Destructor Documentation

NDARRAY_HOST_DEVICE interval ( index_t  min,
index_t  extent 
)
inline

Construct a new interval object. If the min or extent is specified in the constructor, it must have a value compatible with Min or Extent, respectively.

The default values if not specified in the constructor are:

  • The default min is Min if Min is static, or 0 if not.
  • The default extent is Extent if Extent is static, or 1 if not.
NDARRAY_HOST_DEVICE interval ( const interval< CopyMin, CopyExtent > &  other)
inline

Copy construction or assignment of another interval object, possibly with different compile-time template parameters. other.min() and other.extent() must be compatible with Min and Extent, respectively.

Member Function Documentation

NDARRAY_INLINE NDARRAY_HOST_DEVICE index_t min ( ) const
inline

Get or set the first index in this interval.

NDARRAY_INLINE NDARRAY_HOST_DEVICE index_t extent ( ) const
inline

Get or set the number of indices in this interval.

NDARRAY_INLINE NDARRAY_HOST_DEVICE index_t max ( ) const
inline

Get or set the last index in this interval.

NDARRAY_INLINE NDARRAY_HOST_DEVICE bool is_in_range ( index_t  at) const
inline

Returns true if at is within the interval [min(), max()].

NDARRAY_INLINE NDARRAY_HOST_DEVICE bool is_in_range ( const interval< OtherMin, OtherExtent > &  at) const
inline

Returns true if at.min() and at.max() are both within the interval [min(), max()].

NDARRAY_HOST_DEVICE index_iterator begin ( ) const
inline

Make an iterator referring to the first index in this interval.

NDARRAY_HOST_DEVICE index_iterator end ( ) const
inline

Make an iterator referring to one past the last index in this interval.

NDARRAY_HOST_DEVICE bool operator== ( const interval< OtherMin, OtherExtent > &  other) const
inline

Two interval objects are considered equal if they contain the same indices.


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