MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ insert_or_assign()

template<typename K, typename V, typename Compare = std::less<K>>
bool MayaFlux::Memory::FlatMap< K, V, Compare >::insert_or_assign ( const K & key,
V value )
inline

Sets the value for key, adding the entry if it is absent.

Returns
true if the entry was added, false if an existing one was overwritten.

Definition at line 44 of file FlatMap.hpp.

45 {
46 const size_t index = lower_index(key);
47 if (index < m_items.size() && !m_less(key, m_items[index].first)) {
48 m_items[index].second = std::move(value);
49 return false;
50 }
51 m_items.insert(m_items.begin() + static_cast<std::ptrdiff_t>(index), value_type(key, std::move(value)));
52 return true;
53 }
size_t lower_index(const Q &key) const
Definition FlatMap.hpp:129
std::pair< K, V > value_type
Definition FlatMap.hpp:23
std::vector< value_type > m_items
Definition FlatMap.hpp:135
Map kept as one sorted vector, cheap to copy.
Definition FlatMap.hpp:21

Referenced by MayaFlux::Core::VKCommandManager::allocate_from(), MayaFlux::Platform::SystemConfig::get_dep_includes(), MayaFlux::Memory::FlatMap< VkDeviceMemory, vk::DeviceSize >::merge_prefixed(), MayaFlux::Core::NetworkSubsystem::on_backend_state_change(), MayaFlux::Core::NetworkSubsystem::open_endpoint(), MayaFlux::Core::NetworkSubsystem::post_after(), MayaFlux::Core::NetworkSubsystem::set_endpoint_receive_callback(), and MayaFlux::Core::NetworkSubsystem::set_endpoint_state_callback().

Here is the caller graph for this function: