diff --git a/include/Mathter/CMakeLists.txt b/include/Mathter/CMakeLists.txt index 6184ff7..a34f8ff 100644 --- a/include/Mathter/CMakeLists.txt +++ b/include/Mathter/CMakeLists.txt @@ -17,7 +17,6 @@ target_sources(Mathter "Common/Functional.hpp" "Common/OptimizationUtil.hpp" "Common/MathUtil.hpp" - "Common/Range.hpp" "Common/Types.hpp" "Common/TypeTraits.hpp" # Decompositions diff --git a/include/Mathter/Common/Range.hpp b/include/Mathter/Common/Range.hpp deleted file mode 100644 index 89df3ba..0000000 --- a/include/Mathter/Common/Range.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// L============================================================================= -// L This software is distributed under the MIT license. -// L Copyright 2021 Péter Kardos -// L============================================================================= - -#pragma once - - -namespace mathter::impl { - -// Helper for writing for loops as for (auto i : Range(0,10)) -template -class RangeHelper { -public: - class iterator { - friend class RangeHelper; - iterator(T value, T step) : value(value), step(step) {} - - public: - iterator() : value(std::numeric_limits::lowest()) {} - - using value_type = T; - using difference_type = ptrdiff_t; - using reference = T&; - using pointer = T*; - using iterator_category = std::forward_iterator_tag; - - void operator++() { - value += step; - } - T operator*() const { - return value; - } - bool operator==(const iterator& rhs) const { - return value == rhs.value; - } - bool operator!=(const iterator& rhs) const { - return !(*this == rhs); - } - - private: - T value; - T step; - }; - - RangeHelper(T first, T last, T step) : first(first), last(last), step(step) {} - - iterator begin() const { return iterator(first, step); } - iterator end() const { return iterator(last, step); } - iterator cbegin() const { return iterator(first, step); } - iterator cend() const { return iterator(last, step); } - -private: - T first, last, step; -}; - - -template -RangeHelper Range(T first, T last, T step) { - return RangeHelper(first, last, step); -} - -template -RangeHelper Range(T first, T last) { - T step = last >= first ? T(1) : T(-1); - return Range(first, last, step); -} - -template -RangeHelper Range(T last) { - T first = T(0); - T step = last >= first ? T(1) : T(-1); - return Range(first, last, step); -} - -} // namespace mathter::impl \ No newline at end of file