Fix some code style issues

This commit is contained in:
Stefan Müller 2024-12-05 19:31:30 +01:00
parent ffe2d9d443
commit 861a51bad7
3 changed files with 18 additions and 18 deletions

View File

@ -29,7 +29,7 @@ std::string HistorianHysteria::getInputFileName() const
void HistorianHysteria::processDataLine(const std::string& line) void HistorianHysteria::processDataLine(const std::string& line)
{ {
auto pos = line.find(" "); auto pos{ line.find(" ") };
left.insert(std::stoi(line.substr(0, pos))); left.insert(std::stoi(line.substr(0, pos)));
right.insert(std::stoi(line.substr(pos + 3))); right.insert(std::stoi(line.substr(pos + 3)));
} }
@ -38,9 +38,9 @@ void HistorianHysteria::finish()
{ {
int prev{ 0 }; int prev{ 0 };
auto nSame{ 0 }; auto nSame{ 0 };
auto leftIterator = left.begin(); auto leftIterator{ left.begin() };
auto rightIterator = right.begin(); auto rightIterator{ right.begin() };
auto rightSameIterator = right.begin(); auto rightSameIterator{ right.begin() };
while (leftIterator != left.end()) while (leftIterator != left.end())
{ {

View File

@ -15,6 +15,17 @@
#include "Point2.h" #include "Point2.h"
const Point2 Point2::left{ -1, 0 };
const Point2 Point2::right{ 1, 0 };
const Point2 Point2::up{ 0, -1 };
const Point2 Point2::down{ 0, 1 };
const Point2 Point2::upLeft{ -1, -1 };
const Point2 Point2::upRight{ 1, -1 };
const Point2 Point2::downLeft{ -1, 1 };
const Point2 Point2::downRight{ 1, 1 };
const Point2 Point2::directions[] = { Point2::left, Point2::right, Point2::up, Point2::down,
Point2::upLeft, Point2::upRight, Point2::downLeft, Point2::downRight };
Point2::Point2() Point2::Point2()
: Point2{ 0, 0 } {} : Point2{ 0, 0 } {}
@ -68,14 +79,3 @@ Point2& Point2::operator*=(const int rhs)
*this = *this * rhs; *this = *this * rhs;
return *this; return *this;
} }
const Point2 Point2::left{ -1, 0 };
const Point2 Point2::right{ 1, 0 };
const Point2 Point2::up{ 0, -1 };
const Point2 Point2::down{ 0, 1 };
const Point2 Point2::upLeft{ -1, -1 };
const Point2 Point2::upRight{ 1, -1 };
const Point2 Point2::downLeft{ -1, 1 };
const Point2 Point2::downRight{ 1, 1 };
const Point2 Point2::directions[] = { Point2::left, Point2::right, Point2::up, Point2::down,
Point2::upLeft, Point2::upRight, Point2::downLeft, Point2::downRight };

View File

@ -18,6 +18,9 @@
class Point2 class Point2
{ {
public: public:
static const Point2 left, right, up, down;
static const Point2 upLeft, upRight, downLeft, downRight;
static const Point2 directions[8];
int x, y; int x, y;
Point2(); Point2();
Point2(const int x, const int y); Point2(const int x, const int y);
@ -30,7 +33,4 @@ class Point2
Point2& operator+=(const Point2& rhs); Point2& operator+=(const Point2& rhs);
Point2& operator-=(const Point2& rhs); Point2& operator-=(const Point2& rhs);
Point2& operator*=(const int rhs); Point2& operator*=(const int rhs);
static const Point2 left, right, up, down;
static const Point2 upLeft, upRight, downLeft, downRight;
static const Point2 directions[8];
}; };