Stratax 0.2.0
Loading...
Searching...
No Matches
stratax::core::Strides Class Reference

Stores strides for a shape in contiguous memory. More...

#include <Strides.hpp>

Public Types

using iterator = Buffer<std::size_t>::const_iterator
 Iterator over immutable stride values.
using const_iterator = Buffer<std::size_t>::const_iterator
 Const iterator over stride values.
using reverse_iterator = Buffer<std::size_t>::const_reverse_iterator
 Reverse iterator over immutable stride values.
using const_reverse_iterator = Buffer<std::size_t>::const_reverse_iterator
 Const reverse iterator over stride values.

Public Member Functions

 Strides () noexcept=default
 Creates an empty stride vector.
 Strides (const Shape &shape)
 Creates row-major strides for a given shape.
 Strides (const Strides &)=default
 Copies stride metadata.
 Strides (Strides &&) noexcept=default
 Moves stride metadata.
Stridesoperator= (const Strides &)=default
 Copy-assigns stride metadata.
Stridesoperator= (Strides &&) noexcept=default
 Move-assigns stride metadata.
 ~Strides ()=default
 Destroys the stride vector.
std::size_t size () const noexcept
 Returns the number of stored stride values.
bool empty () const noexcept
 Returns whether the stride vector is empty.
std::size_t rank () const noexcept
 Returns the number of dimensions represented by the strides.
const std::size_t & operator() (std::size_t index) const
 Returns a stride value without bounds checking.
const std::size_t & at (std::size_t index) const
 Returns a stride value with bounds checking.
const std::size_t & front () const
 Returns the first stride value.
const std::size_t & back () const
 Returns the last stride value.
const std::size_t * data () const noexcept
 Returns the raw stride data pointer.
iterator begin () noexcept
 Returns an iterator to the first stride value.
const_iterator begin () const noexcept
 Returns a const iterator to the first stride value.
const_iterator cbegin () const noexcept
 Returns a const iterator to the first stride value.
iterator end () noexcept
 Returns an iterator one past the last stride value.
const_iterator end () const noexcept
 Returns a const iterator one past the last stride value.
const_iterator cend () const noexcept
 Returns a const iterator one past the last stride value.
reverse_iterator rbegin () noexcept
 Returns a reverse iterator to the last stride value.
const_reverse_iterator rbegin () const noexcept
 Returns a const reverse iterator to the last stride value.
const_reverse_iterator crbegin () const noexcept
 Returns a const reverse iterator to the last stride value.
reverse_iterator rend () noexcept
 Returns a reverse iterator before the first stride value.
const_reverse_iterator rend () const noexcept
 Returns a const reverse iterator before the first stride value.
const_reverse_iterator crend () const noexcept
 Returns a const reverse iterator before the first stride value.
void swap (Strides &other) noexcept
 Swaps the stored strides with another instance.
bool operator== (const Strides &other) const noexcept
 Compares two stride vectors for equality.
bool operator!= (const Strides &other) const noexcept
 Returns whether two stride vectors differ.

Detailed Description

Stores strides for a shape in contiguous memory.

Strides map logical indices to flat storage offsets, typically for row-major layout. The values are stored as metadata and do not own any array elements.

Definition at line 22 of file Strides.hpp.

Member Typedef Documentation

◆ const_iterator

using stratax::core::Strides::const_iterator = Buffer<std::size_t>::const_iterator

Const iterator over stride values.

Definition at line 32 of file Strides.hpp.

◆ const_reverse_iterator

using stratax::core::Strides::const_reverse_iterator = Buffer<std::size_t>::const_reverse_iterator

Const reverse iterator over stride values.

Definition at line 38 of file Strides.hpp.

◆ iterator

Iterator over immutable stride values.

Definition at line 29 of file Strides.hpp.

◆ reverse_iterator

Reverse iterator over immutable stride values.

Definition at line 35 of file Strides.hpp.

Constructor & Destructor Documentation

◆ Strides()

stratax::core::Strides::Strides ( const Shape & shape)
inlineexplicit

Creates row-major strides for a given shape.

The last dimension receives stride 1 and each preceding dimension is computed from the product of the dimensions to its right.

Parameters
shapeSource shape used to derive stride values.
Exceptions
Exceptions::DimensionErrorIf stride computation overflows.

Definition at line 55 of file Strides.hpp.

Member Function Documentation

◆ at()

const std::size_t & stratax::core::Strides::at ( std::size_t index) const
inline

Returns a stride value with bounds checking.

Parameters
indexStride index.
Returns
Const reference to the requested stride value.
Exceptions
Exceptions::IndexErrorIf the index is out of bounds.

Definition at line 141 of file Strides.hpp.

◆ back()

const std::size_t & stratax::core::Strides::back ( ) const
inline

Returns the last stride value.

Returns
Const reference to the last stride value.

Definition at line 162 of file Strides.hpp.

◆ begin() [1/2]

const_iterator stratax::core::Strides::begin ( ) const
inlinenodiscardnoexcept

Returns a const iterator to the first stride value.

Returns
Const iterator to the beginning of the stride storage.

Definition at line 192 of file Strides.hpp.

◆ begin() [2/2]

iterator stratax::core::Strides::begin ( )
inlinenodiscardnoexcept

Returns an iterator to the first stride value.

Returns
Iterator to the beginning of the stride storage.

Definition at line 182 of file Strides.hpp.

◆ cbegin()

const_iterator stratax::core::Strides::cbegin ( ) const
inlinenodiscardnoexcept

Returns a const iterator to the first stride value.

Returns
Const iterator to the beginning of the stride storage.

Definition at line 202 of file Strides.hpp.

◆ cend()

const_iterator stratax::core::Strides::cend ( ) const
inlinenodiscardnoexcept

Returns a const iterator one past the last stride value.

Returns
Const iterator to the end of the stride storage.

Definition at line 232 of file Strides.hpp.

◆ crbegin()

const_reverse_iterator stratax::core::Strides::crbegin ( ) const
inlinenodiscardnoexcept

Returns a const reverse iterator to the last stride value.

Returns
Const reverse iterator starting at the last stride value.

Definition at line 262 of file Strides.hpp.

◆ crend()

const_reverse_iterator stratax::core::Strides::crend ( ) const
inlinenodiscardnoexcept

Returns a const reverse iterator before the first stride value.

Returns
Const reverse iterator representing the end sentinel.

Definition at line 292 of file Strides.hpp.

◆ data()

const std::size_t * stratax::core::Strides::data ( ) const
inlinenodiscardnoexcept

Returns the raw stride data pointer.

Returns
Pointer to the first stored stride, or nullptr when empty.

Definition at line 172 of file Strides.hpp.

◆ empty()

bool stratax::core::Strides::empty ( ) const
inlinenodiscardnoexcept

Returns whether the stride vector is empty.

Returns
true when no strides are stored.

Definition at line 104 of file Strides.hpp.

◆ end() [1/2]

const_iterator stratax::core::Strides::end ( ) const
inlinenodiscardnoexcept

Returns a const iterator one past the last stride value.

Returns
Const iterator to the end of the stride storage.

Definition at line 222 of file Strides.hpp.

◆ end() [2/2]

iterator stratax::core::Strides::end ( )
inlinenodiscardnoexcept

Returns an iterator one past the last stride value.

Returns
Iterator to the end of the stride storage.

Definition at line 212 of file Strides.hpp.

◆ front()

const std::size_t & stratax::core::Strides::front ( ) const
inline

Returns the first stride value.

Returns
Const reference to the first stride value.

Definition at line 152 of file Strides.hpp.

◆ operator!=()

bool stratax::core::Strides::operator!= ( const Strides & other) const
inlinenodiscardnoexcept

Returns whether two stride vectors differ.

Parameters
otherStrides object to compare against.
Returns
true when the stride vectors are not equal.

Definition at line 336 of file Strides.hpp.

◆ operator()()

const std::size_t & stratax::core::Strides::operator() ( std::size_t index) const
inline

Returns a stride value without bounds checking.

Parameters
indexStride index.
Returns
Const reference to the requested stride value.
Warning
The caller must ensure that the index is in range.

Definition at line 127 of file Strides.hpp.

◆ operator==()

bool stratax::core::Strides::operator== ( const Strides & other) const
inlinenodiscardnoexcept

Compares two stride vectors for equality.

Parameters
otherStrides object to compare against.
Returns
true when the stride vectors match exactly.

Definition at line 314 of file Strides.hpp.

◆ rank()

std::size_t stratax::core::Strides::rank ( ) const
inlinenodiscardnoexcept

Returns the number of dimensions represented by the strides.

Returns
Rank of the stride vector.

Definition at line 114 of file Strides.hpp.

◆ rbegin() [1/2]

const_reverse_iterator stratax::core::Strides::rbegin ( ) const
inlinenodiscardnoexcept

Returns a const reverse iterator to the last stride value.

Returns
Const reverse iterator starting at the last stride value.

Definition at line 252 of file Strides.hpp.

◆ rbegin() [2/2]

reverse_iterator stratax::core::Strides::rbegin ( )
inlinenodiscardnoexcept

Returns a reverse iterator to the last stride value.

Returns
Reverse iterator starting at the last stride value.

Definition at line 242 of file Strides.hpp.

◆ rend() [1/2]

const_reverse_iterator stratax::core::Strides::rend ( ) const
inlinenodiscardnoexcept

Returns a const reverse iterator before the first stride value.

Returns
Const reverse iterator representing the end sentinel.

Definition at line 282 of file Strides.hpp.

◆ rend() [2/2]

reverse_iterator stratax::core::Strides::rend ( )
inlinenodiscardnoexcept

Returns a reverse iterator before the first stride value.

Returns
Reverse iterator representing the end sentinel.

Definition at line 272 of file Strides.hpp.

◆ size()

std::size_t stratax::core::Strides::size ( ) const
inlinenodiscardnoexcept

Returns the number of stored stride values.

Returns
Number of stored stride values.

Definition at line 94 of file Strides.hpp.

◆ swap()

void stratax::core::Strides::swap ( Strides & other)
inlinenoexcept

Swaps the stored strides with another instance.

Parameters
otherStrides object to exchange state with.

Definition at line 302 of file Strides.hpp.


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