PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | List of all members
PIVector2D< T >::Row Class Reference

Proxy class representing a single row in a PIVector2D for modification. Objects of this class are returned by non-const operator[] or row(). They provide array-like access to the elements of a specific row and allow operations such as assignment from another row or a PIVector, searching, filling, and iteration. More...

#include <pivector2d.h>

Inheritance diagram for PIVector2D< T >::Row:
Inheritance graph
[legend]

Public Member Functions

T & operator[] (size_t index)
 Accesses the element at the given column index within the row. No bounds checking is performed; use with caution. More...
 
T * data (size_t index=0)
 Returns a pointer to the row data starting at an optional offset. The pointer can be used for direct memory operations. It remains valid as long as the underlying 2D array is not reallocated.
 
Rowoperator= (const Row &other)
 Assigns the contents of another Row to this row. Only the minimum of the two row sizes is copied; if this row is shorter, excess elements in other are ignored. More...
 
Rowoperator= (const PIVector< T > &other)
 Assigns the contents of a PIVector to this row. Only the minimum of the row size and vector size is copied. More...
 
void forEach (std::function< void(T &)> func)
 Applies a function to each element of the row (modifiable). The function can modify the elements. More...
 
void fill (const T &value)
 Fills the row with copies of value. More...
 
const T * data (size_t index=0) const
 Returns a const pointer to the row data starting at an optional offset.
 
size_t size () const
 Size of the row (number of columns).
 
- Public Member Functions inherited from PIVector2D< T >::RowConst
 RowConst (const PIVector2D< T >::Row &r)
 Copy constructor from modifiable Row to read-only RowConst. More...
 
size_t size () const
 Size of the row (number of columns).
 
const T & operator[] (size_t index) const
 Const access to the element at the given column index within the row.
 
const T * data (size_t index=0) const
 Returns a const pointer to the row data starting at an optional offset.
 
PIVector< T > toVector () const
 Converts the row to a PIVector.
 
ssize_t indexOf (const T &e, ssize_t start=0) const
 Returns the first index of element e in the row, starting from start. See PIVector::indexOf() for details on negative start handling. More...
 
ssize_t lastIndexOf (const T &e, ssize_t start=-1) const
 Returns the last index of element e in the row, searching backwards from start. More...
 
ssize_t indexWhere (std::function< bool(const T &e)> test, ssize_t start=0) const
 Returns the first index where the predicate test returns true, starting from start. More...
 
ssize_t lastIndexWhere (std::function< bool(const T &e)> test, ssize_t start=-1) const
 Returns the last index where the predicate test returns true, searching backwards from start. More...
 
void forEach (std::function< void(const T &)> func) const
 Applies a function to each element of the row (read-only). The function can't modify the elements. More...
 
bool contains (const T &e, ssize_t start=0) const
 Checks if the row contains the element e. More...
 
int entries (const T &e, ssize_t start=0) const
 Counts occurrences of e in the row. More...
 
int entries (std::function< bool(const T &e)> test, ssize_t start=0) const
 Counts elements in the row that pass the test. More...
 
bool any (std::function< bool(const T &e)> test) const
 Tests if any element in the row passes the test. More...
 
bool every (std::function< bool(const T &e)> test) const
 Tests if all elements in the row pass the test. More...
 

Detailed Description

template<typename T>
class PIVector2D< T >::Row

Proxy class representing a single row in a PIVector2D for modification. Objects of this class are returned by non-const operator[] or row(). They provide array-like access to the elements of a specific row and allow operations such as assignment from another row or a PIVector, searching, filling, and iteration.

Member Function Documentation

◆ operator[]()

template<typename T >
T & PIVector2D< T >::Row::operator[] ( size_t  index)
inline

Accesses the element at the given column index within the row. No bounds checking is performed; use with caution.

See also
PIVector::operator[]

◆ operator=() [1/2]

template<typename T >
Row & PIVector2D< T >::Row::operator= ( const Row other)
inline

Assigns the contents of another Row to this row. Only the minimum of the two row sizes is copied; if this row is shorter, excess elements in other are ignored.

See also
PIVector::operator=

◆ operator=() [2/2]

template<typename T >
Row & PIVector2D< T >::Row::operator= ( const PIVector< T > &  other)
inline

Assigns the contents of a PIVector to this row. Only the minimum of the row size and vector size is copied.

See also
PIVector::operator=

◆ forEach()

template<typename T >
void PIVector2D< T >::Row::forEach ( std::function< void(T &)>  func)
inline

Applies a function to each element of the row (modifiable). The function can modify the elements.

See also
PIVector::forEach()

◆ fill()

template<typename T >
void PIVector2D< T >::Row::fill ( const T &  value)
inline

Fills the row with copies of value.

See also
PIVector::fill()