diff options
Diffstat (limited to 'include/cru/common/Range.h')
| -rw-r--r-- | include/cru/common/Range.h | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/include/cru/common/Range.h b/include/cru/common/Range.h deleted file mode 100644 index edc2ec55..00000000 --- a/include/cru/common/Range.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once -#include "Base.h" - -namespace cru { -struct Range final { - constexpr static Range FromTwoSides(Index start, Index end) { - return Range(start, end - start); - } - - constexpr static Range FromTwoSides(Index start, Index end, Index offset) { - return Range(start + offset, end - start); - } - - constexpr Range() = default; - constexpr Range(const Index position, const Index count = 0) - : position(position), count(count) {} - - Index GetStart() const { return position; } - Index GetEnd() const { return position + count; } - - void ChangeEnd(Index new_end) { count = new_end - position; } - - Range Normalize() const { - auto result = *this; - if (result.count < 0) { - result.position += result.count; - result.count = -result.count; - } - return result; - } - - Range CoerceInto(Index min, Index max) const { - auto coerce = [min, max](Index index) { - return index > max ? max : (index < min ? min : index); - }; - return Range::FromTwoSides(coerce(GetStart()), coerce(GetEnd())); - } - - Index position = 0; - Index count = 0; -}; -} // namespace cru |
