Add Index access methods and validation functions to PIVector2D
- Add operator[], element(), and at() overloads for Index struct - Add isValid() and isNotValid() methods to Index - Add default initialization to -1 (invalid state) - Add parameterized constructor Index(row, col) - Add tests for new functionality
This commit is contained in:
@@ -55,8 +55,14 @@ public:
|
||||
//! \~english Index structure for 2D array elements (row, column).
|
||||
//! \~russian Структура индекса для элементов двумерного массива (строка, столбец).
|
||||
struct Index {
|
||||
ssize_t row;
|
||||
ssize_t col;
|
||||
ssize_t row = -1;
|
||||
ssize_t col = -1;
|
||||
|
||||
inline Index() = default;
|
||||
inline Index(ssize_t r, ssize_t c): row(r), col(c) {}
|
||||
|
||||
inline bool isValid() const { return row >= 0 && col >= 0; }
|
||||
inline bool isNotValid() const { return !isValid(); }
|
||||
};
|
||||
|
||||
//! \~english Constructs an empty 2D array. No memory is allocated.
|
||||
|
||||
Reference in New Issue
Block a user