diff options
author | Adrian Kummerlaender | 2016-12-11 13:39:33 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2016-12-11 13:39:33 +0100 |
commit | 6622e436442e37190c43aa40770f0f01bc2427e9 (patch) | |
tree | 1d0c3d72ba0f35a51ceea9dfb7e387255755db48 | |
parent | 245d40cb5618aa7c12d9109bc45e817be8d0e7b8 (diff) | |
download | termlife-6622e436442e37190c43aa40770f0f01bc2427e9.tar termlife-6622e436442e37190c43aa40770f0f01bc2427e9.tar.gz termlife-6622e436442e37190c43aa40770f0f01bc2427e9.tar.bz2 termlife-6622e436442e37190c43aa40770f0f01bc2427e9.tar.lz termlife-6622e436442e37190c43aa40770f0f01bc2427e9.tar.xz termlife-6622e436442e37190c43aa40770f0f01bc2427e9.tar.zst termlife-6622e436442e37190c43aa40770f0f01bc2427e9.zip |
Move non-template classes into distinct compilation units
-rw-r--r-- | src/util/box_indicator.cc | 28 | ||||
-rw-r--r-- | src/util/box_indicator.h | 24 | ||||
-rw-r--r-- | src/util/box_traverser.cc | 16 | ||||
-rw-r--r-- | src/util/box_traverser.h | 9 |
4 files changed, 54 insertions, 23 deletions
diff --git a/src/util/box_indicator.cc b/src/util/box_indicator.cc new file mode 100644 index 0000000..4f68f91 --- /dev/null +++ b/src/util/box_indicator.cc @@ -0,0 +1,28 @@ +#include "box_indicator.h" + +namespace life { +namespace util { + +BoxIndicator::BoxIndicator( + const std::size_t offset_x, + const std::size_t offset_y, + const std::size_t size_x, + const std::size_t size_y +): + a_x_{offset_x}, + a_y_{offset_y}, + b_x_{a_x_ + size_x}, + b_y_{a_y_ + size_y} { } + +BoxIndicator::BoxIndicator(const std::size_t size_x, const std::size_t size_y): + BoxIndicator(0, 0, size_x, size_y) { } + +bool BoxIndicator::operator()(const std::size_t x, const std::size_t y) const { + return x >= this->a_x_ + && x < this->b_x_ + && y >= this->a_y_ + && y < this->b_y_; +} + +} +} diff --git a/src/util/box_indicator.h b/src/util/box_indicator.h index c0493c7..b93264b 100644 --- a/src/util/box_indicator.h +++ b/src/util/box_indicator.h @@ -1,30 +1,22 @@ #ifndef LIFE_SRC_UTIL_BOX_INDICATOR_ #define LIFE_SRC_UTIL_BOX_INDICATOR_ +#include <cstdint> + namespace life { namespace util { class BoxIndicator { public: - BoxIndicator( + BoxIndicator( const std::size_t offset_x, const std::size_t offset_y, const std::size_t size_x, - const std::size_t size_y): - a_x_{offset_x}, - a_y_{offset_y}, - b_x_{a_x_ + size_x}, - b_y_{a_y_ + size_y} { } - - BoxIndicator(const std::size_t size_x, const std::size_t size_y): - BoxIndicator(0, 0, size_x, size_y) { } - - bool operator()(const std::size_t x, const std::size_t y) const { - return x >= this->a_x_ - && x < this->b_x_ - && y >= this->a_y_ - && y < this->b_y_; - } + const std::size_t size_y); + + BoxIndicator(const std::size_t size_x, const std::size_t size_y); + + bool operator()(const std::size_t x, const std::size_t y) const; protected: const std::size_t a_x_; diff --git a/src/util/box_traverser.cc b/src/util/box_traverser.cc new file mode 100644 index 0000000..bba9f94 --- /dev/null +++ b/src/util/box_traverser.cc @@ -0,0 +1,16 @@ +#include "box_traverser.h" + +namespace life { +namespace util { + +void BoxTraverser::for_each( + const std::function<void(std::size_t, std::size_t)>& f) const { + for ( std::size_t x = this->a_x_; x < this->b_x_; x++ ) { + for ( std::size_t y = this->a_y_; y < this->b_y_; y++ ) { + f(x, y); + } + } +} + +} +} diff --git a/src/util/box_traverser.h b/src/util/box_traverser.h index cb7dfeb..d59d871 100644 --- a/src/util/box_traverser.h +++ b/src/util/box_traverser.h @@ -1,6 +1,7 @@ #ifndef LIFE_SRC_UTIL_BOX_TRAVERSER_ #define LIFE_SRC_UTIL_BOX_TRAVERSER_ +#include <cstdint> #include <functional> #include "box_indicator.h" @@ -11,13 +12,7 @@ namespace util { struct BoxTraverser : public BoxIndicator { using BoxIndicator::BoxIndicator; - void for_each(const std::function<void(std::size_t, std::size_t)> f) const { - for ( std::size_t x = this->a_x_; x < this->b_x_; x++ ) { - for ( std::size_t y = this->a_y_; y < this->b_y_; y++ ) { - f(x, y); - } - } - } + void for_each(const std::function<void(std::size_t, std::size_t)>& f) const; }; } |