|
Py2Cpp 1.6.3; VERSION ${PROJECT_VERSION}
|
Python-like dictionary implementation. More...
#include <dict.hpp>


Public Types | |
| using | value_type = std::pair< const Key, T > |
| using | key_type = Key |
Public Member Functions | |
| dict () | |
| Default constructor. | |
| dict (std::initializer_list< value_type > init) | |
| Construct a dict from an initializer list. | |
| auto | contains (const Key &key) const -> bool |
| Check if the dictionary contains a specific key. | |
| auto | get (const Key &key, const T &default_value) const -> T |
| Get a value with a default fallback. | |
| auto | begin () -> key_iterator< decltype(Base::begin())> |
| Get iterator to the beginning of keys. | |
| auto | end () -> key_iterator< decltype(Base::end())> |
| Get iterator to the end of keys. | |
| auto | begin () const -> key_iterator< decltype(Base::begin())> |
| Get const iterator to the beginning of keys. | |
| auto | end () const -> key_iterator< decltype(Base::end())> |
| Get const iterator to the end of keys. | |
| auto | items () -> Base & |
| Get the underlying map for iteration. | |
| auto | items () const -> const Base & |
| Get the underlying map for iteration (const version) | |
| auto | copy () const -> Self |
| Create a copy of the dictionary. | |
| auto | operator[] (const Key &k) const -> const T & |
| Access value by key (const version) | |
| auto | at (const Key &k) const -> const T & |
| Access value by key with bounds checking (const version) | |
| auto | operator[] (const Key &k) -> T & |
| Access or insert value by key. | |
| auto | operator= (const Self &) -> Self &=delete |
| Copy assignment operator (deleted) | |
| auto | operator= (Self &&) noexcept -> dict &=default |
| Move assignment operator. | |
| dict (dict< Key, T > &&) noexcept=default | |
| Move Constructor (default) | |
| ~dict ()=default | |
| dict (const dict< Key, T > &)=default | |
| Construct a new dict object. | |
Python-like dictionary implementation.
A dictionary class that extends std::unordered_map with Python-like convenience methods and functionality.
| Key | The key type |
| T | The value type |
| using py::dict< Key, T >::key_type = Key |
| using py::dict< Key, T >::value_type = std::pair<const Key, T> |
|
inline |
Default constructor.
Creates an empty dictionary.
|
inline |
Construct a dict from an initializer list.
Creates a dictionary from a list of key-value pairs.
| [in] | init | Initializer list of key-value pairs |
Move Constructor (default)
Construct a new dict object.
Copy through explicitly the public copy() function!!!
|
inline |
Access value by key with bounds checking (const version)
Returns a const reference to the value associated with the key. Throws std::out_of_range if the key is not found.
| [in] | k | The key to look up |
|
inline |
Get iterator to the beginning of keys.
Returns an iterator that yields keys from the dictionary.
|
inline |
Get const iterator to the beginning of keys.
Returns a const iterator that yields keys from the dictionary.
|
inline |
Check if the dictionary contains a specific key.
| [in] | key | The key to look up |
Create a copy of the dictionary.
|
inline |
Get iterator to the end of keys.
Returns an iterator past the last key in the dictionary.
|
inline |
Get const iterator to the end of keys.
Returns a const iterator past the last key in the dictionary.
|
inline |
Get a value with a default fallback.
Returns the value associated with the key, or the default value if the key is not found in the dictionary.
| [in] | key | The key to look up |
| [in] | default_value | The default value to return if key is not found |
|
inline |
Get the underlying map for iteration.
|
inline |
Get the underlying map for iteration (const version)
|
delete |
Copy assignment operator (deleted)
Use copy() method instead for explicit copying.
|
defaultnoexcept |
Move assignment operator.
|
inline |
Access or insert value by key.
Returns a reference to the value associated with the key. If the key does not exist, inserts a default-constructed value.
| [in] | k | The key to look up |
|
inline |
Access value by key (const version)
Returns a const reference to the value associated with the key. Throws std::out_of_range if the key is not found.
| [in] | k | The key to look up |