diff --git a/openVulkanoCpp/Data/Containers/RangeSet.hpp b/openVulkanoCpp/Data/Containers/RangeSet.hpp new file mode 100644 index 0000000..89c9ebf --- /dev/null +++ b/openVulkanoCpp/Data/Containers/RangeSet.hpp @@ -0,0 +1,44 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "Math/Range.hpp" +#include + +namespace OpenVulkano +{ + template + class RangeSet + { + std::vector> m_ranges; + + public: + RangeSet() = default; + + RangeSet(const std::vector>& ranges) : m_ranges(ranges) {} + + RangeSet(std::vector>&& ranges) : m_ranges(std::move(ranges)) {} + + [[nodiscard]] bool ContainsInclusive(const T& value) const + { + for(const auto& range : m_ranges) + { + if (range.InBounds(value)) return true; + } + return false; + } + + [[nodiscard]] bool Contains(const T& value) const + { + for(const auto& range : m_ranges) + { + if (range.Inside(value)) return true; + } + return false; + } + }; +}