25#ifndef LSST_AFW_TYPEHANDLING_SIMPLEGENERICMAP_H
26#define LSST_AFW_TYPEHANDLING_SIMPLEGENERICMAP_H
30#include <unordered_map>
38namespace typehandling {
70 _storage = other._storage;
73 swap(_keyView, newKeys);
81 _storage = _convertStorage(other);
83 swap(_keyView, newKeys);
89 bool empty() const noexcept
override {
return _storage.
empty(); }
95 bool contains(K
const& key)
const override {
return _storage.
count(key) > 0; }
99 void clear() noexcept
override {
113 message <<
"Key not found: " << key;
126 swap(_keyView, newKeys);
133 for (
auto it = newKeys.
cbegin(); it != newKeys.
cend();) {
135 it = newKeys.
erase(it);
141 bool erased = _storage.
erase(key) > 0;
144 swap(_keyView, newKeys);
167 map.
apply([&newStorage](K
const& key,
auto const& value) { newStorage.
emplace(key, value); });
#define LSST_EXCEPT(type,...)
Interface for a heterogeneous map.
decltype(_typeToConstRef(std::declval< StorableType >())) ConstValueReference
A type-agnostic reference to the value stored inside the map.
std::variant< bool, int, long, long long, float, double, std::string, PolymorphicValue, std::shared_ptr< Storable const > > StorableType
The types that can be stored in a map.
auto apply(Visitor &&visitor) const
Apply an operation to each key-value pair in the map.
Interface for a GenericMap that allows element addition and removal.
A GenericMap that allows insertion and deletion of arbitrary values.
virtual ~SimpleGenericMap() noexcept=default
void clear() noexcept override
Remove all of the mappings from this map.
std::vector< K > const & keys() const noexcept override
Return the set of all keys, without type information.
GenericMap< K >::size_type size() const noexcept override
Return the number of key-value pairs in the map.
SimpleGenericMap(SimpleGenericMap const &other)=default
bool unsafeErase(K key) override
Remove the mapping for a key from this map, if it exists.
bool empty() const noexcept override
Return true if this map contains no key-value pairs.
SimpleGenericMap()=default
SimpleGenericMap & operator=(SimpleGenericMap &&) noexcept=default
bool contains(K const &key) const override
Return true if this map contains a mapping whose key has the specified label.
ConstValueReference unsafeLookup(K key) const override
Return a reference to the mapped value of the element with key equal to key.
GenericMap< K >::size_type max_size() const noexcept override
Return the maximum number of elements the container is able to hold due to system or library implemen...
bool unsafeInsert(K key, StorableType &&value) override
Create a new mapping with key equal to key and value equal to value.
SimpleGenericMap(SimpleGenericMap &&) noexcept=default
T emplace_back(T... args)
void swap(PolymorphicValue &lhs, PolymorphicValue &rhs) noexcept
Swap specialization for PolymorphicValue.
A base class for image defects.
T throw_with_nested(T... args)