tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
Public Member Functions | List of all members
tatami::ArrayView< T > Class Template Reference

View into a pre-allocated array. More...

#include <ArrayView.hpp>

Public Member Functions

 ArrayView (const T *ptr, size_t number)
 
 ArrayView ()
 
size_t size () const
 
const Tdata () const
 
const Tbegin () const
 
const Tend () const
 
T operator[] (size_t i) const
 

Detailed Description

template<typename T>
class tatami::ArrayView< T >

View into a pre-allocated array.

This allows us to use a pre-existing array in the tatami classes, assuming that the array lives longer than the view created on it. We provide some methods to mimic a std::vector for use within the tatami constructors. This is implemented in lieu of having access to C++20's std::span class.

Template Parameters
TArray type, usually numeric.

Constructor & Destructor Documentation

◆ ArrayView() [1/2]

template<typename T >
tatami::ArrayView< T >::ArrayView ( const T ptr,
size_t  number 
)
inline
Parameters
[in]ptrPointer to the start of the array. The lifetime of the array is assumed to exceed that of the constructed ArrayView instance.
numberNumber of array elements.

◆ ArrayView() [2/2]

template<typename T >
tatami::ArrayView< T >::ArrayView ( )
inline

Default constructor to create a zero-length view.

Member Function Documentation

◆ size()

template<typename T >
size_t tatami::ArrayView< T >::size ( ) const
inline
Returns
Number of array elements.

◆ data()

template<typename T >
const T * tatami::ArrayView< T >::data ( ) const
inline
Returns
Pointer to the start of the array.

◆ begin()

template<typename T >
const T * tatami::ArrayView< T >::begin ( ) const
inline
Returns
Pointer to the start of the array, for use in templated functions expecting a std::vector.

◆ end()

template<typename T >
const T * tatami::ArrayView< T >::end ( ) const
inline
Returns
Pointer to the end of the array, for use in templated functions expecting a std::vector.

◆ operator[]()

template<typename T >
T tatami::ArrayView< T >::operator[] ( size_t  i) const
inline
Parameters
iIndex of the array.
Returns
Value of the array at element i.

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