Skip to content

Commit

Permalink
Convert size_t to int consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysgoldstein committed Feb 1, 2024
1 parent 24751ae commit 6326d74
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion analysis/AnalyzeBenchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ BenchmarkResult AnalyzeBenchmark(const std::filesystem::path& mapFilePath,
if (!inputCells.empty() && !scenarios.empty()) {
auto planner = PathPlanner<L>{ inputCells, alignment, searchMethod, smoothingMethod, centralize };
if (scenarioIndex >= 0) {
if (scenarioIndex >= scenarios.size()) {
if (scenarioIndex >= int(scenarios.size())) {
printf("Warning: Scenario index %d must be less than number of scenarios (%d)\n", scenarioIndex, int(scenarios.size()));
printf("\n");
}
Expand Down
7 changes: 4 additions & 3 deletions include/central64/grid/Grid2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Grid2D<L>::Grid2D(const std::vector<std::vector<bool>>& inputCells,
// Store the centered-aligned grid cells.
centerCells_ = Array2D<bool>{ {nx, ny}, false };
for (int y = 0; y < ny; ++y) {
assert(inputCells[y].size() == nx);
assert(int(inputCells[y].size()) == nx);
for (int x = 0; x < nx; ++x) {
centerCells_[{x, y}] = inputCells[y][x];
}
Expand Down Expand Up @@ -108,7 +108,7 @@ Grid2D<L>::Grid2D(const std::vector<std::vector<bool>>& inputCells,
centerCells_ = Array2D<bool>{ {nx, ny}, true };
cornerCells_ = Array2D<bool>{ {nx - 1, ny - 1}, false };
for (int y = 0; y < ny - 1; ++y) {
assert(inputCells[y].size() == nx - 1);
assert(int(inputCells[y].size()) == nx - 1);
for (int x = 0; x < nx - 1; ++x) {
cornerCells_[{x, y}] = inputCells[y][x];
centerCells_[{x, y}] = centerCells_[{x, y}] && inputCells[y][x];
Expand Down Expand Up @@ -331,7 +331,8 @@ inline std::string ToString(const Grid2D<L>& grid, const std::vector<Offset2D>&
// Each path vertex is assigned the last digit of its index.
// All grid vertices that are not part of the path are set to -1.
Array2D<int> path2D{ grid.Dims(), -1 };
for (int i = 0; i < pathVertices.size(); ++i) {
int vertexCount = int(pathVertices.size());
for (int i = 0; i < vertexCount; ++i) {
path2D[pathVertices[i]] = i%10;
}

Expand Down
6 changes: 4 additions & 2 deletions include/central64/grid/Offset2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ inline std::string ToString(const std::vector<Offset2D>& pathVertices,
std::string vertexDelimiter = ", ")
{
std::string pathString{};
for (int i = 0; i < pathVertices.size(); ++i) {
int vertexCount = int(pathVertices.size());
for (int i = 0; i < vertexCount; ++i) {
if (i > 0) {
pathString += vertexDelimiter;
}
Expand All @@ -88,7 +89,8 @@ inline double PathLength(const std::vector<Offset2D>& pathVertices)
pathLength = std::numeric_limits<double>::infinity();
}
else {
for (int i = 0; i < pathVertices.size() - 1; ++i) {
int vertexCount = int(pathVertices.size());
for (int i = 0; i < vertexCount - 1; ++i) {
const Offset2D offset = pathVertices[i + 1] - pathVertices[i];
pathLength += sqrt(offset.X()*offset.X() + offset.Y()*offset.Y());
}
Expand Down

0 comments on commit 6326d74

Please sign in to comment.