|
lsst.afw
17.0.1-24-g0055ebd3c+3
|
Interface for a GenericMap that allows element addition and removal. More...
#include <GenericMap.h>
Public Types | |
| using | key_type = K |
| using | size_type = std::size_t |
| using | difference_type = std::ptrdiff_t |
Public Member Functions | |
| virtual | ~MutableGenericMap () noexcept=default |
| virtual void | clear () noexcept=0 |
| Remove all of the mappings from this map. More... | |
| template<typename T > | |
| bool | insert (Key< K, T > const &key, T const &value) |
| Insert an element into the map, if the map doesn't already contain a mapping with the same or a conflicting key. More... | |
| template<typename T > | |
| std::pair< Key< K, T >, bool > | insert (K const &key, T const &value) |
| Insert an element into the map, if the map doesn't already contain a mapping with a conflicting key. More... | |
| template<typename T > | |
| bool | erase (Key< K, T > const &key) |
| Remove the mapping for a key from this map, if it exists. More... | |
| virtual size_type | size () const noexcept=0 |
| Return the number of key-value pairs in the map. More... | |
| virtual bool | empty () const noexcept=0 |
Return true if this map contains no key-value pairs. More... | |
| virtual size_type | max_size () const noexcept=0 |
| Return the maximum number of elements the container is able to hold due to system or library implementation limitations. More... | |
| template<typename T > | |
| size_type | count (Key< K, T > const &key) const |
| Return the number of elements mapped to the specified key. More... | |
| virtual bool | contains (K const &key) const =0 |
Return true if this map contains a mapping whose key has the specified label. More... | |
| virtual std::vector< K > | keys () const =0 |
| Return the set of all keys, without type information. More... | |
| template<typename T , typename std::enable_if_t<!IS_SMART_PTR< T >, int > = 0> | |
| T & | at (Key< K, T > const &key) |
Return a reference to the mapped value of the element with key equal to key. More... | |
| template<typename T , typename std::enable_if_t< std::is_fundamental< T >::value||std::is_base_of< std::string, T >::value, int > = 0> | |
| T const & | at (Key< K, T > const &key) const |
Return a reference to the mapped value of the element with key equal to key. More... | |
| template<typename T , typename std::enable_if_t< std::is_base_of< Storable, T >::value, int > = 0> | |
| T const & | at (Key< K, T > const &key) const |
Return a reference to the mapped value of the element with key equal to key. More... | |
| template<typename T , typename std::enable_if_t< std::is_base_of< Storable, T >::value, int > = 0> | |
| std::shared_ptr< T > | at (Key< K, std::shared_ptr< T >> const &key) const |
Return a reference to the mapped value of the element with key equal to key. More... | |
| template<typename T , typename std::enable_if_t< std::is_fundamental< T >::value||std::is_base_of< std::string, T >::value, int > = 0> | |
| bool | contains (Key< K, T > const &key) const |
Return true if this map contains a mapping for the specified key. More... | |
| template<typename T , typename std::enable_if_t< std::is_base_of< Storable, T >::value, int > = 0> | |
| bool | contains (Key< K, T > const &key) const |
Return true if this map contains a mapping for the specified key. More... | |
| template<typename T , typename std::enable_if_t< std::is_base_of< Storable, T >::value, int > = 0> | |
| bool | contains (Key< K, std::shared_ptr< T >> const &key) const |
Return true if this map contains a mapping for the specified key. More... | |
| virtual bool | operator== (GenericMap const &other) const |
| Test for map equality. More... | |
| bool | operator!= (GenericMap const &other) const |
| Test for map equality. More... | |
Protected Types | |
| using | ValueReference = boost::variant< bool const &, std::int32_t const &, std::int64_t const &, float const &, double const &, std::string const &, PolymorphicValue const &, std::shared_ptr< Storable > const & > |
| A type-agnostic reference to the value stored inside the map. More... | |
| using | StorableType = decltype(_referenceToType(std::declval< ValueReference >())) |
| The types that can be stored in a map. More... | |
Protected Member Functions | |
| virtual bool | unsafeInsert (K key, StorableType &&value)=0 |
Create a new mapping with key equal to key and value equal to value. More... | |
| virtual bool | unsafeErase (K key)=0 |
| Remove the mapping for a key from this map, if it exists. More... | |
| virtual ValueReference | unsafeLookup (K key) const =0 |
Return a reference to the mapped value of the element with key equal to key. More... | |
Interface for a GenericMap that allows element addition and removal.
In Python, a MutableGenericMap behaves like a collections.abc.MutableMapping.
operator[] or insert_or_assign. This is because these operations would have surprising behavior when dealing with keys of different types but the same Key::getId(). Definition at line 562 of file GenericMap.h.
|
inherited |
Definition at line 233 of file GenericMap.h.
|
inherited |
Definition at line 231 of file GenericMap.h.
|
inherited |
Definition at line 232 of file GenericMap.h.
|
protectedinherited |
The types that can be stored in a map.
These are the pass-by-value equivalents (using std::decay) of ValueReference.
Definition at line 522 of file GenericMap.h.
|
protectedinherited |
A type-agnostic reference to the value stored inside the map.
Keys of any subclass of Storable are implemented using PolymorphicValue to preserve type.
Definition at line 514 of file GenericMap.h.
|
virtualdefaultnoexcept |
|
inlineinherited |
Return a reference to the mapped value of the element with key equal to key.
| T | the type of the element mapped to key |
| key | the key of the element to find |
T mapped to key, if one exists| pex::exceptions::OutOfRangeError | Thrown if the map does not have a T with the specified key |
Definition at line 255 of file GenericMap.h.
|
inlineinherited |
Return a reference to the mapped value of the element with key equal to key.
| T | the type of the element mapped to key |
| key | the key of the element to find |
T mapped to key, if one exists| pex::exceptions::OutOfRangeError | Thrown if the map does not have a T with the specified key |
Definition at line 264 of file GenericMap.h.
|
inlineinherited |
Return a reference to the mapped value of the element with key equal to key.
| T | the type of the element mapped to key |
| key | the key of the element to find |
T mapped to key, if one exists| pex::exceptions::OutOfRangeError | Thrown if the map does not have a T with the specified key |
Definition at line 278 of file GenericMap.h.
|
inlineinherited |
Return a reference to the mapped value of the element with key equal to key.
| T | the type of the element mapped to key |
| key | the key of the element to find |
T mapped to key, if one exists| pex::exceptions::OutOfRangeError | Thrown if the map does not have a T with the specified key |
Definition at line 301 of file GenericMap.h.
|
pure virtualnoexcept |
Remove all of the mappings from this map.
After this call, the map will be empty.
Implemented in lsst::afw::typehandling::SimpleGenericMap< K >.
|
pure virtualinherited |
Return true if this map contains a mapping whose key has the specified label.
More formally, this method returns true if and only if this map contains a mapping with a key k such that k.getId() == key. There can be at most one such mapping.
| key | the weakly-typed key to search for |
true if this map contains a mapping for key, regardless of value type.Implemented in lsst::afw::typehandling::SimpleGenericMap< K >.
|
inlineinherited |
Return true if this map contains a mapping for the specified key.
This is equivalent to testing whether at(key) would succeed.
| T | the value corresponding to key |
| key | the key to search for |
true if this map contains a mapping from the specified key to a Ttrue, it calls unsafeLookup, then uses templates and RTTI to determine if the value is of the expected type. The performance of this method depends strongly on the performance of contains(K const&). Definition at line 397 of file GenericMap.h.
|
inlineinherited |
Return true if this map contains a mapping for the specified key.
This is equivalent to testing whether at(key) would succeed.
| T | the value corresponding to key |
| key | the key to search for |
true if this map contains a mapping from the specified key to a Ttrue, it calls unsafeLookup, then uses templates and RTTI to determine if the value is of the expected type. The performance of this method depends strongly on the performance of contains(K const&). Definition at line 414 of file GenericMap.h.
|
inlineinherited |
Return true if this map contains a mapping for the specified key.
This is equivalent to testing whether at(key) would succeed.
| T | the value corresponding to key |
| key | the key to search for |
true if this map contains a mapping from the specified key to a Ttrue, it calls unsafeLookup, then uses templates and RTTI to determine if the value is of the expected type. The performance of this method depends strongly on the performance of contains(K const&). Definition at line 432 of file GenericMap.h.
|
inlineinherited |
Return the number of elements mapped to the specified key.
| T | the value corresponding to key |
| key | key value of the elements to count |
T with key key, that is, either 1 or 0.Definition at line 355 of file GenericMap.h.
|
pure virtualnoexceptinherited |
Return true if this map contains no key-value pairs.
Implemented in lsst::afw::typehandling::SimpleGenericMap< K >.
|
inline |
Remove the mapping for a key from this map, if it exists.
| T | the type of value the key maps to |
| key | the key to remove |
true if key was removed, false if it was not presentDefinition at line 641 of file GenericMap.h.
|
inline |
Insert an element into the map, if the map doesn't already contain a mapping with the same or a conflicting key.
| T | the type of value to insert |
| key | key to insert |
| value | value to insert |
true if the insertion took place, false otherwiseT to prevent insertion. Callers can safely assume this->contains(key.getId()) as a postcondition, but not this->contains(key).Definition at line 595 of file GenericMap.h.
|
inline |
Insert an element into the map, if the map doesn't already contain a mapping with a conflicting key.
| T | the type of value to insert |
| key | key to insert |
| value | value to insert |
true if the insertion took place and false otherwiseDefinition at line 619 of file GenericMap.h.
|
pure virtualinherited |
Return the set of all keys, without type information.
Implemented in lsst::afw::typehandling::SimpleGenericMap< K >.
|
pure virtualnoexceptinherited |
Return the maximum number of elements the container is able to hold due to system or library implementation limitations.
Implemented in lsst::afw::typehandling::SimpleGenericMap< K >.
|
inlineinherited |
Test for map equality.
Two GenericMap objects are considered equal if they map the same keys to the same values. The two objects do not need to have the same implementation class. If either class orders its keys, the order is ignored.
Definition at line 493 of file GenericMap.h.
|
inlinevirtualinherited |
Test for map equality.
Two GenericMap objects are considered equal if they map the same keys to the same values. The two objects do not need to have the same implementation class. If either class orders its keys, the order is ignored.
Definition at line 479 of file GenericMap.h.
|
pure virtualnoexceptinherited |
Return the number of key-value pairs in the map.
Implemented in lsst::afw::typehandling::SimpleGenericMap< K >.
|
protectedpure virtual |
Remove the mapping for a key from this map, if it exists.
| key | the key to remove |
true if key was removed, false if it was not presentImplemented in lsst::afw::typehandling::SimpleGenericMap< K >.
|
protectedpure virtual |
Create a new mapping with key equal to key and value equal to value.
This method is the primary way to implement the MutableGenericMap interface.
| key | the key of the element to insert. The method may assume that the map does not contain key. |
| value | a reference to the value to insert. |
true if the insertion took place, false otherwiseImplemented in lsst::afw::typehandling::SimpleGenericMap< K >.
|
protectedpure virtualinherited |
Return a reference to the mapped value of the element with key equal to key.
This method is the primary way to implement the GenericMap interface.
| key | the key of the element to find |
key, if one exists| pex::exceptions::OutOfRangeError | Thrown if the map does not have a value with the specified key |
Implemented in lsst::afw::typehandling::SimpleGenericMap< K >.
1.8.13