mirror of
https://github.com/JHUAPL/kami.git
synced 2026-01-09 14:58:02 -05:00
Rename x/y accessors
This commit is contained in:
@@ -56,7 +56,7 @@ namespace kami {
|
||||
/**
|
||||
* @brief Return the `x` coordinate
|
||||
*/
|
||||
[[nodiscard]] int get_x_location() const;
|
||||
[[nodiscard]] int x() const;
|
||||
|
||||
/**
|
||||
* @brief Convert the coordinate to a human-readable string.
|
||||
@@ -314,7 +314,7 @@ namespace std {
|
||||
template<>
|
||||
struct hash<kami::GridCoord1D> {
|
||||
size_t operator()(const kami::GridCoord1D &key) const {
|
||||
return (hash<int>()(key.get_x_location()));
|
||||
return (hash<int>()(key.x()));
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
@@ -58,12 +58,12 @@ namespace kami {
|
||||
/**
|
||||
* @brief Get the coordinate in the first dimension or `x`.
|
||||
*/
|
||||
[[nodiscard]] int get_x_location() const;
|
||||
[[nodiscard]] int x() const;
|
||||
|
||||
/**
|
||||
* @brief Get the coordinate in the second dimension or `y`.
|
||||
*/
|
||||
[[nodiscard]] int get_y_location() const;
|
||||
[[nodiscard]] int y() const;
|
||||
|
||||
/**
|
||||
* @brief Convert the coordinate to a human-readable string.
|
||||
@@ -380,7 +380,7 @@ namespace std {
|
||||
template<>
|
||||
struct hash<kami::GridCoord2D> {
|
||||
size_t operator()(const kami::GridCoord2D &key) const {
|
||||
return ((hash<int>()(key.get_x_location()) ^ (hash<int>()(key.get_y_location()) << 1)) >> 1);
|
||||
return ((hash<int>()(key.x()) ^ (hash<int>()(key.y()) << 1)) >> 1);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace kami {
|
||||
|
||||
GridCoord1D::GridCoord1D(int x_coord) : _x_coord(x_coord) {}
|
||||
|
||||
int GridCoord1D::get_x_location() const {
|
||||
int GridCoord1D::x() const {
|
||||
return _x_coord;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace kami {
|
||||
}
|
||||
|
||||
bool Grid1D::is_location_valid(const GridCoord1D &coord) const {
|
||||
auto x = coord.get_x_location();
|
||||
auto x = coord.x();
|
||||
|
||||
return (x >= 0 && x < static_cast<int>(_maximum_x));
|
||||
}
|
||||
@@ -193,7 +193,7 @@ namespace kami {
|
||||
}
|
||||
|
||||
GridCoord1D Grid1D::coord_wrap(const GridCoord1D &coord) const {
|
||||
auto x = coord.get_x_location();
|
||||
auto x = coord.x();
|
||||
|
||||
if (_wrap_x)
|
||||
x = (x + static_cast<int>(_maximum_x)) % static_cast<int>(_maximum_x);
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
|
||||
namespace kami {
|
||||
|
||||
int GridCoord2D::get_x_location() const {
|
||||
int GridCoord2D::x() const {
|
||||
return _x_coord;
|
||||
}
|
||||
|
||||
int GridCoord2D::get_y_location() const {
|
||||
int GridCoord2D::y() const {
|
||||
return _y_coord;
|
||||
}
|
||||
|
||||
@@ -140,8 +140,8 @@ namespace kami {
|
||||
}
|
||||
|
||||
bool Grid2D::is_location_valid(const GridCoord2D &coord) const {
|
||||
auto x = coord.get_x_location();
|
||||
auto y = coord.get_y_location();
|
||||
auto x = coord.x();
|
||||
auto y = coord.y();
|
||||
|
||||
return (x >= 0 && x < static_cast<int>(_maximum_x) &&
|
||||
y >= 0 && y < static_cast<int>(_maximum_y));
|
||||
@@ -236,8 +236,8 @@ namespace kami {
|
||||
}
|
||||
|
||||
GridCoord2D Grid2D::coord_wrap(const GridCoord2D &coord) const {
|
||||
auto x = coord.get_x_location();
|
||||
auto y = coord.get_y_location();
|
||||
auto x = coord.x();
|
||||
auto y = coord.y();
|
||||
|
||||
if (_wrap_x)
|
||||
x = (x + static_cast<int>(_maximum_x)) % static_cast<int>(_maximum_x);
|
||||
|
||||
@@ -71,17 +71,17 @@ TEST_F(GridCoord1DTest, inequality) {
|
||||
EXPECT_TRUE(gridcoord1d_bar != gridcoord1d_baz);
|
||||
}
|
||||
|
||||
TEST_F(GridCoord1DTest, get_x_location) {
|
||||
EXPECT_TRUE(gridcoord1d_foo.get_x_location() == 0);
|
||||
EXPECT_TRUE(gridcoord1d_bar.get_x_location() == 1);
|
||||
EXPECT_TRUE(gridcoord1d_baz.get_x_location() == -1);
|
||||
TEST_F(GridCoord1DTest, x) {
|
||||
EXPECT_TRUE(gridcoord1d_foo.x() == 0);
|
||||
EXPECT_TRUE(gridcoord1d_bar.x() == 1);
|
||||
EXPECT_TRUE(gridcoord1d_baz.x() == -1);
|
||||
|
||||
EXPECT_TRUE(gridcoord1d_foo.get_x_location() == gridcoord1d_foo.get_x_location());
|
||||
EXPECT_TRUE(gridcoord1d_foo.get_x_location() == gridcoord1d_qux.get_x_location());
|
||||
EXPECT_TRUE(gridcoord1d_foo.x() == gridcoord1d_foo.x());
|
||||
EXPECT_TRUE(gridcoord1d_foo.x() == gridcoord1d_qux.x());
|
||||
|
||||
EXPECT_FALSE(gridcoord1d_foo.get_x_location() == gridcoord1d_bar.get_x_location());
|
||||
EXPECT_FALSE(gridcoord1d_foo.get_x_location() == gridcoord1d_baz.get_x_location());
|
||||
EXPECT_FALSE(gridcoord1d_bar.get_x_location() == gridcoord1d_baz.get_x_location());
|
||||
EXPECT_FALSE(gridcoord1d_foo.x() == gridcoord1d_bar.x());
|
||||
EXPECT_FALSE(gridcoord1d_foo.x() == gridcoord1d_baz.x());
|
||||
EXPECT_FALSE(gridcoord1d_bar.x() == gridcoord1d_baz.x());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
@@ -97,52 +97,52 @@ TEST_F(GridCoord2DTest, Inequality) {
|
||||
EXPECT_TRUE(gridcoord2d_qux != gridcoord2d_qu2);
|
||||
}
|
||||
|
||||
TEST_F(GridCoord2DTest, get_x_location) {
|
||||
TEST_F(GridCoord2DTest, x) {
|
||||
const GridCoord2D gridcoord2d_foo(0, 0);
|
||||
const GridCoord2D gridcoord2d_bar(1, 1);
|
||||
const GridCoord2D gridcoord2d_baz(-1, -1);
|
||||
const GridCoord2D gridcoord2d_qux(0, 1);
|
||||
const GridCoord2D gridcoord2d_qu2(1, 0);
|
||||
|
||||
EXPECT_TRUE(gridcoord2d_foo.get_x_location() == 0);
|
||||
EXPECT_TRUE(gridcoord2d_bar.get_x_location() == 1);
|
||||
EXPECT_TRUE(gridcoord2d_baz.get_x_location() == -1);
|
||||
EXPECT_FALSE(gridcoord2d_qux.get_x_location() == -1);
|
||||
EXPECT_FALSE(gridcoord2d_qu2.get_x_location() == -1);
|
||||
EXPECT_TRUE(gridcoord2d_foo.x() == 0);
|
||||
EXPECT_TRUE(gridcoord2d_bar.x() == 1);
|
||||
EXPECT_TRUE(gridcoord2d_baz.x() == -1);
|
||||
EXPECT_FALSE(gridcoord2d_qux.x() == -1);
|
||||
EXPECT_FALSE(gridcoord2d_qu2.x() == -1);
|
||||
|
||||
EXPECT_TRUE(gridcoord2d_foo.get_x_location() == gridcoord2d_foo.get_x_location());
|
||||
EXPECT_TRUE(gridcoord2d_foo.get_x_location() == gridcoord2d_qux.get_x_location());
|
||||
EXPECT_TRUE(gridcoord2d_bar.get_x_location() == gridcoord2d_qu2.get_x_location());
|
||||
EXPECT_TRUE(gridcoord2d_foo.x() == gridcoord2d_foo.x());
|
||||
EXPECT_TRUE(gridcoord2d_foo.x() == gridcoord2d_qux.x());
|
||||
EXPECT_TRUE(gridcoord2d_bar.x() == gridcoord2d_qu2.x());
|
||||
|
||||
EXPECT_FALSE(gridcoord2d_foo.get_x_location() == gridcoord2d_bar.get_x_location());
|
||||
EXPECT_FALSE(gridcoord2d_foo.get_x_location() == gridcoord2d_baz.get_x_location());
|
||||
EXPECT_FALSE(gridcoord2d_bar.get_x_location() == gridcoord2d_baz.get_x_location());
|
||||
EXPECT_FALSE(gridcoord2d_foo.get_x_location() == gridcoord2d_baz.get_x_location());
|
||||
EXPECT_FALSE(gridcoord2d_qux.get_x_location() == gridcoord2d_qu2.get_x_location());
|
||||
EXPECT_FALSE(gridcoord2d_foo.x() == gridcoord2d_bar.x());
|
||||
EXPECT_FALSE(gridcoord2d_foo.x() == gridcoord2d_baz.x());
|
||||
EXPECT_FALSE(gridcoord2d_bar.x() == gridcoord2d_baz.x());
|
||||
EXPECT_FALSE(gridcoord2d_foo.x() == gridcoord2d_baz.x());
|
||||
EXPECT_FALSE(gridcoord2d_qux.x() == gridcoord2d_qu2.x());
|
||||
}
|
||||
|
||||
TEST_F(GridCoord2DTest, get_y_location) {
|
||||
TEST_F(GridCoord2DTest, y) {
|
||||
const GridCoord2D gridcoord2d_foo(0, 0);
|
||||
const GridCoord2D gridcoord2d_bar(1, 1);
|
||||
const GridCoord2D gridcoord2d_baz(-1, -1);
|
||||
const GridCoord2D gridcoord2d_qux(0, 1);
|
||||
const GridCoord2D gridcoord2d_qu2(1, 0);
|
||||
|
||||
EXPECT_TRUE(gridcoord2d_foo.get_y_location() == 0);
|
||||
EXPECT_TRUE(gridcoord2d_bar.get_y_location() == 1);
|
||||
EXPECT_TRUE(gridcoord2d_baz.get_y_location() == -1);
|
||||
EXPECT_FALSE(gridcoord2d_qux.get_y_location() == -1);
|
||||
EXPECT_FALSE(gridcoord2d_qu2.get_y_location() == -1);
|
||||
EXPECT_TRUE(gridcoord2d_foo.y() == 0);
|
||||
EXPECT_TRUE(gridcoord2d_bar.y() == 1);
|
||||
EXPECT_TRUE(gridcoord2d_baz.y() == -1);
|
||||
EXPECT_FALSE(gridcoord2d_qux.y() == -1);
|
||||
EXPECT_FALSE(gridcoord2d_qu2.y() == -1);
|
||||
|
||||
EXPECT_TRUE(gridcoord2d_foo.get_y_location() == gridcoord2d_foo.get_y_location());
|
||||
EXPECT_TRUE(gridcoord2d_bar.get_y_location() == gridcoord2d_qux.get_y_location());
|
||||
EXPECT_TRUE(gridcoord2d_foo.y() == gridcoord2d_foo.y());
|
||||
EXPECT_TRUE(gridcoord2d_bar.y() == gridcoord2d_qux.y());
|
||||
|
||||
EXPECT_FALSE(gridcoord2d_foo.get_y_location() == gridcoord2d_bar.get_y_location());
|
||||
EXPECT_FALSE(gridcoord2d_foo.get_y_location() == gridcoord2d_baz.get_y_location());
|
||||
EXPECT_FALSE(gridcoord2d_bar.get_y_location() == gridcoord2d_baz.get_y_location());
|
||||
EXPECT_FALSE(gridcoord2d_foo.get_y_location() == gridcoord2d_baz.get_y_location());
|
||||
EXPECT_FALSE(gridcoord2d_qux.get_y_location() == gridcoord2d_qu2.get_y_location());
|
||||
EXPECT_FALSE(gridcoord2d_bar.get_y_location() == gridcoord2d_qu2.get_y_location());
|
||||
EXPECT_FALSE(gridcoord2d_foo.y() == gridcoord2d_bar.y());
|
||||
EXPECT_FALSE(gridcoord2d_foo.y() == gridcoord2d_baz.y());
|
||||
EXPECT_FALSE(gridcoord2d_bar.y() == gridcoord2d_baz.y());
|
||||
EXPECT_FALSE(gridcoord2d_foo.y() == gridcoord2d_baz.y());
|
||||
EXPECT_FALSE(gridcoord2d_qux.y() == gridcoord2d_qu2.y());
|
||||
EXPECT_FALSE(gridcoord2d_bar.y() == gridcoord2d_qu2.y());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
Reference in New Issue
Block a user