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:
2026-02-27 00:41:51 +03:00
parent 56ff28c793
commit 14e62a41bd
2 changed files with 41 additions and 2 deletions

View File

@@ -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.