Template Class SimpleGenericMap¶
Defined in File SimpleGenericMap.h
Inheritance Relationships¶
Base Type¶
public lsst::afw::typehandling::MutableGenericMap< K >
(Template Class MutableGenericMap)
Class Documentation¶
-
template<typename
K
>
classSimpleGenericMap
: public lsst::afw::typehandling::MutableGenericMap<K>¶ A GenericMap that allows insertion and deletion of arbitrary values.
In Python, a SimpleGenericMap behaves like a
dict
. In particular, it will iterate over keys in the order they were added.- Template Parameters
K
: the key type of the map. Must be hashable.
Public Functions
-
SimpleGenericMap
()¶
-
SimpleGenericMap
(SimpleGenericMap const &other)¶
-
SimpleGenericMap
(SimpleGenericMap&&)¶
-
SimpleGenericMap
(GenericMap<K> const &other)¶ Convert another GenericMap into a SimpleGenericMap.
This constructor will insert key-value pairs following
other
’s iteration order. This may not be the order in which they were inserted into the original map.
-
virtual
~SimpleGenericMap
()¶
-
SimpleGenericMap &
operator=
(SimpleGenericMap const &other)¶
-
SimpleGenericMap &
operator=
(SimpleGenericMap&&)¶
-
SimpleGenericMap &
operator=
(GenericMap<K> const &other)¶
-
bool
empty
() const¶ Return
true
if this map contains no key-value pairs.
-
GenericMap<K>::size_type
max_size
() const¶ Return the maximum number of elements the container is able to hold due to system or library implementation limitations.
- Note
This value typically reflects the theoretical limit on the size of the container. At runtime, the size of the container may be limited to a value smaller than max_size() by the amount of RAM available.
-
bool
contains
(K const &key) const¶ 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 keyk
such thatk.getId() == key
. There can be at most one such mapping.Provides strong exception safety.
- Return
true
if this map contains a mapping forkey
, regardless of value type.- Parameters
key
: the weakly-typed key to search for
-
std::vector<K> const &
keys
() const¶ Return the set of all keys, without type information.
- Return
a read-only view of all keys currently in the map, in the same iteration order as this object. The view will be updated by changes to the underlying map.
- Warning
Do not modify this map while iterating over its keys.
- Warning
Do not store the returned reference in variables that outlive the map; destroying the map will invalidate the reference.
- Note
The keys are returned as a list, rather than a set, so that subclasses can give them a well-defined iteration order.
-
void
clear
()¶ Remove all of the mappings from this map.
After this call, the map will be empty.
Protected Functions
-
ConstValueReference
unsafeLookup
(K key) const¶ 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.
- Return
the value mapped to
key
, if one exists- Parameters
key
: the key of the element to find
- Exceptions
pex::exceptions::OutOfRangeError
: Thrown if the map does not have a value with the specified key Must provide strong exception safety.
-
bool
unsafeInsert
(K key, StorableType &&value)¶ Create a new mapping with key equal to
key
and value equal tovalue
.This method is the primary way to implement the MutableGenericMap interface.
Must provide strong exception safety.
- Return
true
if the insertion took place,false
otherwise- Parameters
key
: the key of the element to insert. The method may assume that the map does not containkey
.value
: a reference to the value to insert.
-
bool
unsafeErase
(K key)¶ Remove the mapping for a key from this map, if it exists.
Must provide strong exception safety.
- Return
true
ifkey
was removed,false
if it was not present- Parameters
key
: the key to remove