Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AsPJT committed Feb 11, 2019
1 parent 632caa8 commit 6552704
Show file tree
Hide file tree
Showing 15 changed files with 4,202 additions and 3,421 deletions.
719 changes: 389 additions & 330 deletions include/cpp14/BoardGame.hpp

Large diffs are not rendered by default.

109 changes: 59 additions & 50 deletions include/cpp14/DungeonBinarization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,75 @@

//Dungeon Template Library Namespace
namespace dtl {
namespace utility {

//2値化処理
template<typename Matrix_Int_, typename Matrix_>
constexpr void dungeonBinarization(Matrix_& matrix_, const Matrix_Int_ value_) noexcept {
for (std::size_t row{}; row < matrix_.size(); ++row)
for (std::size_t col{}; col < matrix_[row].size(); ++col) {
if (static_cast<Matrix_Int_>(matrix_[row][col]) >= value_) matrix_[row][col] = static_cast<Matrix_Int_>(1);
else matrix_[row][col] = static_cast<Matrix_Int_>(0);
}
}
namespace stl {

template<typename Matrix_Int_, typename Matrix_>
constexpr void dungeonBinarization_RangeBasedFor(Matrix_& matrix_, const Matrix_Int_ value_) noexcept {
for (auto&& row : matrix_)
for (auto&& col : row) {
if (col >= value_) col = static_cast<Matrix_Int_>(1);
else col = static_cast<Matrix_Int_>(0);
//2値化処理
template<typename Matrix_>
constexpr void binarization(Matrix_& matrix_) noexcept {
for (std::size_t row{}; row < matrix_.size(); ++row)
for (std::size_t col{}; col < matrix_[row].size(); ++col) {
if (matrix_[row][col]) matrix_[row][col] = 1;
else matrix_[row][col] = 0;
}
}
}

template<typename Matrix_>
constexpr void dungeonBinarization(Matrix_& matrix_) noexcept {
for (std::size_t row{}; row < matrix_.size(); ++row)
for (std::size_t col{}; col < matrix_[row].size(); ++col) {
if (matrix_[row][col]) matrix_[row][col] = 1;
else matrix_[row][col] = 0;
template<typename Matrix_Int_, typename Matrix_>
constexpr void binarizationOver(Matrix_& matrix_, const Matrix_Int_ value_) noexcept {
for (std::size_t row{}; row < matrix_.size(); ++row)
for (std::size_t col{}; col < matrix_[row].size(); ++col) {
if (static_cast<Matrix_Int_>(matrix_[row][col]) >= value_) matrix_[row][col] = static_cast<Matrix_Int_>(1);
else matrix_[row][col] = static_cast<Matrix_Int_>(0);
}
}
}

template<typename Matrix_>
constexpr void dungeonBinarization_RangeBasedFor(Matrix_& matrix_) noexcept {
for (auto&& row : matrix_)
for (auto&& col : row) {
if (col) col = 1;
else col = 0;
template<typename Matrix_, typename STL2_>
constexpr void binarizationBool(Matrix_& matrix_, STL2_& stl2_) noexcept {
if (matrix_.size() != stl2_.size()) return;
for (std::size_t row{}; row < matrix_.size(); ++row)
for (std::size_t col{}; col < matrix_[row].size(); ++col) {
if (matrix_[row].size() != stl2_[row].size()) continue;
if (matrix_[row][col]) stl2_[row][col] = true;
else stl2_[row][col] = false;
}
}
}

template<typename Matrix_, typename STL2_>
constexpr void dungeonBinarizationBool(Matrix_& matrix_, STL2_& stl2_) noexcept {
if (matrix_.size() != stl2_.size()) return;
for (std::size_t row{}; row < matrix_.size(); ++row)
for (std::size_t col{}; col < matrix_[row].size(); ++col) {
if (matrix_[row].size() != stl2_[row].size()) continue;
if (matrix_[row][col]) stl2_[row][col] = true;
else stl2_[row][col] = false;
template<typename Matrix_, typename STL2_, typename Matrix_Int_>
constexpr void binarizationBool(Matrix_& matrix_, STL2_& stl2_, const Matrix_Int_ value_) noexcept {
if (matrix_.size() != stl2_.size()) return;
for (std::size_t row{}; row < matrix_.size(); ++row)
for (std::size_t col{}; col < matrix_[row].size(); ++col) {
if (matrix_[row].size() != stl2_[row].size()) continue;
if (matrix_[row][col] >= value_) stl2_[row][col] = true;
else stl2_[row][col] = false;
}
}
}

template<typename Matrix_, typename STL2_, typename Matrix_Int_>
constexpr void dungeonBinarizationBool(Matrix_& matrix_, STL2_& stl2_, const Matrix_Int_ value_) noexcept {
if (matrix_.size() != stl2_.size()) return;
for (std::size_t row{}; row < matrix_.size(); ++row)
for (std::size_t col{}; col < matrix_[row].size(); ++col) {
if (matrix_[row].size() != stl2_[row].size()) continue;
if (matrix_[row][col] >= value_) stl2_[row][col] = true;
else stl2_[row][col] = false;
}

namespace rangeBasedFor {

template<typename Matrix_Int_, typename Matrix_>
constexpr void binarization(Matrix_& matrix_, const Matrix_Int_ value_) noexcept {
for (auto&& row : matrix_)
for (auto&& col : row) {
if (col >= value_) col = static_cast<Matrix_Int_>(1);
else col = static_cast<Matrix_Int_>(0);
}
}
}
template<typename Matrix_>
constexpr void binarization(Matrix_& matrix_) noexcept {
for (auto&& row : matrix_)
for (auto&& col : row) {
if (col) col = 1;
else col = 0;
}
}

}



} //namespace
}

#endif //Included Dungeon Template Library
Loading

0 comments on commit 6552704

Please sign in to comment.