45 lines
920 B
C++
45 lines
920 B
C++
/*
|
|
* 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 <vector>
|
|
|
|
namespace OpenVulkano
|
|
{
|
|
template<typename T>
|
|
class RangeSet
|
|
{
|
|
std::vector<Math::Range<T>> m_ranges;
|
|
|
|
public:
|
|
RangeSet() = default;
|
|
|
|
RangeSet(const std::vector<Math::Range<T>>& ranges) : m_ranges(ranges) {}
|
|
|
|
RangeSet(std::vector<Math::Range<T>>&& 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;
|
|
}
|
|
};
|
|
}
|