20template <
typename K,
typename V,
typename Compare = std::less<K>>
28 [[nodiscard]]
size_t size() const noexcept {
return m_items.size(); }
29 [[nodiscard]]
bool empty() const noexcept {
return m_items.empty(); }
36 ?
m_items.begin() +
static_cast<std::ptrdiff_t
>(index)
48 m_items[index].second = std::move(value);
62 requires(!std::same_as<Q, K> &&
requires {
typename Compare::is_transparent; })
67 ?
m_items.begin() +
static_cast<std::ptrdiff_t
>(index)
78 m_items.erase(
m_items.begin() +
static_cast<std::ptrdiff_t
>(index));
84 requires(!std::same_as<Q, K> &&
requires {
typename Compare::is_transparent; })
91 m_items.erase(
m_items.begin() +
static_cast<std::ptrdiff_t
>(index));
107 std::string& error,
bool replace =
false)
108 requires std::same_as<
K,
std::
string>
111 for (
const auto& entry : other.
m_items) {
112 const std::string target = std::string(prefix) + entry.first;
114 error =
"already has an entry named " + target;
119 for (
const auto& entry : other.
m_items) {
128 template <
typename Q = K>
131 const auto it = std::ranges::lower_bound(
m_items, key,
m_less, &value_type::first);
132 return static_cast<size_t>(it -
m_items.begin());
size_t size() const noexcept
size_t lower_index(const Q &key) const
bool empty() const noexcept
const_iterator end() const noexcept
bool insert_or_assign(const K &key, V value)
Sets the value for key, adding the entry if it is absent.
std::pair< VkDeviceMemory, vk::DeviceSize > value_type
bool merge_prefixed(const FlatMap &other, std::string_view prefix, std::string &error, bool replace=false)
Adds every entry of other under a name prefix.
const_iterator find(const K &key) const
The entry for key, or end() when absent.
typename std::vector< value_type >::const_iterator const_iterator
bool erase(const K &key)
Removes the entry for key.
std::vector< value_type > m_items
const_iterator find(const Q &key) const
The entry for a key of another type, or end() when absent.
const_iterator begin() const noexcept
bool erase(const Q &key)
Removes the entry for a key of another type, as find does for lookup.
Map kept as one sorted vector, cheap to copy.