Clustering
C++20 header-only: DBSCAN, HDBSCAN, k-means.
Loading...
Searching...
No Matches
clustering::NDArray< T, N, L >::ConstAccessor Class Reference

Provides read-only access to NDArray elements. More...

#include <clustering/ndarray.h>

Inheritance diagram for clustering::NDArray< T, N, L >::ConstAccessor:
[legend]
Collaboration diagram for clustering::NDArray< T, N, L >::ConstAccessor:
[legend]

Public Member Functions

 ConstAccessor (const NDArray< T, N, Layout::Contig > &ndarray, std::size_t index, std::size_t dim)
 Constructs a ConstAccessor for a constant NDArray.
 ConstAccessor (const ConstAccessor &other)=default
 Defaulted copy constructor; accessors are lightweight and trivially copyable.
ConstAccessor operator[] (std::size_t index) const noexcept
 Provides access to the next dimension of the NDArray.
 operator T () const noexcept
 Converts the accessor to the element type T, allowing read access to the element.
size_t index () const noexcept
 Returns the flat index in the NDArray corresponding to the accessor.
Public Member Functions inherited from clustering::NDArray< T, N, L >::BaseAccessor
const T * data () const
 Returns a pointer to the element data.

Additional Inherited Members

Protected Member Functions inherited from clustering::NDArray< T, N, L >::BaseAccessor
 BaseAccessor (NDArray< T, N, Layout::Contig > *ndarray, std::size_t index, std::size_t dim)
 Constructs a BaseAccessor for a given NDArray, index, and dimension.
Protected Attributes inherited from clustering::NDArray< T, N, L >::BaseAccessor
NDArray< T, N, Layout::Contig > * m_ndarray
 Pointer to the NDArray.
std::size_t m_index
 Index in the flat representation of the array.
std::size_t m_dim
 Current dimension of the accessor.

Detailed Description

template<class T, std::size_t N, Layout L = Layout::Contig>
class clustering::NDArray< T, N, L >::ConstAccessor

Provides read-only access to NDArray elements.

Definition at line 184 of file ndarray.h.

Constructor & Destructor Documentation

◆ ConstAccessor() [1/2]

template<class T, std::size_t N, Layout L = Layout::Contig>
clustering::NDArray< T, N, L >::ConstAccessor::ConstAccessor ( const NDArray< T, N, Layout::Contig > & ndarray,
std::size_t index,
std::size_t dim )
inline

Constructs a ConstAccessor for a constant NDArray.

Parameters
ndarrayReference to the constant NDArray.
indexIndex for the desired element.
dimCurrent dimension for the accessor.

Definition at line 193 of file ndarray.h.

◆ ConstAccessor() [2/2]

template<class T, std::size_t N, Layout L = Layout::Contig>
clustering::NDArray< T, N, L >::ConstAccessor::ConstAccessor ( const ConstAccessor & other)
default

Defaulted copy constructor; accessors are lightweight and trivially copyable.

Member Function Documentation

◆ index()

template<class T, std::size_t N, Layout L = Layout::Contig>
size_t clustering::NDArray< T, N, L >::ConstAccessor::index ( ) const
inlinenodiscardnoexcept

Returns the flat index in the NDArray corresponding to the accessor.

Returns
The flat index as a size_t.

Definition at line 225 of file ndarray.h.

◆ operator T()

template<class T, std::size_t N, Layout L = Layout::Contig>
clustering::NDArray< T, N, L >::ConstAccessor::operator T ( ) const
inlinenoexcept

Converts the accessor to the element type T, allowing read access to the element.

Returns
The element of type T at the accessor's position.

Definition at line 218 of file ndarray.h.

◆ operator[]()

template<class T, std::size_t N, Layout L = Layout::Contig>
ConstAccessor clustering::NDArray< T, N, L >::ConstAccessor::operator[] ( std::size_t index) const
inlinenoexcept

Provides access to the next dimension of the NDArray.

Parameters
indexIndex in the next dimension.
Returns
A new ConstAccessor for the specified index in the next dimension.

Definition at line 205 of file ndarray.h.


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