Proton  1.1.1
Make porting easy from Python to C++11
proton::map_< K, T, C, A > Class Template Reference

a map extension implementing python's dict-like interfaces. More...

#include <proton/map.hpp>

Inherits std::map< K, T >.

List of all members.

Public Member Functions

template<typename... argT>
 map_ (argT &&...a)
 forwarding ctor.
 map_ (std::initializer_list< itemT > a)
 initializer_list forwarding ctor.
 map_ (const map_ &x)
 copy ctor.
 map_ (map_ &&x) noexcept
 move ctor.
map_operator= (const map_ &x)
 assign.
 operator baseT & ()
 cast to std::set<>&.
void del (const K &key)
 remove an item.
get (const K &key) const
 get an item from the map.
template<typename... D>
get (const K &key, D &&...dft) const
 get an item from the map.
bool has_key (const K &key) const
 deprecated, using has()
pop (const K &key)
 pop an item from the map.
template<typename... D>
pop (const K &key, D &&...dft)
 pop an item from the map.
itemT popitem ()
 pop the first item.
template<typename... D>
const T & setdefault (const K &key, D &&...dft)
 If key exists, return its value.
template<typename oT >
void update (oT &&o)
 Update the map with the key/value pairs from other, overwriting existing keys.

Additional Inherited Members

- Public Attributes inherited from std::map< K, T >
keys
 STL member.
elements
 STL member.

Detailed Description

template<typename K, typename T, typename C = std::less<K>, typename A = smart_allocator<std::pair<const K,T> >>
class proton::map_< K, T, C, A >

a map extension implementing python's dict-like interfaces.

Definition at line 80 of file map.hpp.


Member Function Documentation

template<typename K , typename T , typename C = std::less<K>, typename A = smart_allocator<std::pair<const K,T> >>
void proton::map_< K, T, C, A >::del ( const K &  key)
inline

remove an item.

Parameters:
keythe key.
Exceptions:
std::out_of_rangeif there is no such a value.

Definition at line 163 of file map.hpp.

template<typename K , typename T , typename C = std::less<K>, typename A = smart_allocator<std::pair<const K,T> >>
T proton::map_< K, T, C, A >::get ( const K &  key) const
inline

get an item from the map.

Parameters:
keythe key of the item
Returns:
the corresponding value.
Exceptions:
std::out_of_rangeif there is no such a key.

Definition at line 177 of file map.hpp.

References proton::at().

template<typename K , typename T , typename C = std::less<K>, typename A = smart_allocator<std::pair<const K,T> >>
template<typename... D>
T proton::map_< K, T, C, A >::get ( const K &  key,
D &&...  dft 
) const
inline

get an item from the map.

Parameters:
keythe key of the item
dftthe default value
Returns:
the corresponding value, if the key doesn't exist, return the default.

Definition at line 188 of file map.hpp.

template<typename K , typename T , typename C = std::less<K>, typename A = smart_allocator<std::pair<const K,T> >>
T proton::map_< K, T, C, A >::pop ( const K &  key)
inline

pop an item from the map.

Parameters:
keythe key of the item
Returns:
the corresponding value.
Exceptions:
proton::errif there is no such a key.

Definition at line 210 of file map.hpp.

References PROTON_THROW_IF.

template<typename K , typename T , typename C = std::less<K>, typename A = smart_allocator<std::pair<const K,T> >>
template<typename... D>
T proton::map_< K, T, C, A >::pop ( const K &  key,
D &&...  dft 
)
inline

pop an item from the map.

Parameters:
keythe key of the item
dftthe default value
Returns:
the corresponding value, if the key doesn't exist, return the default.

Definition at line 225 of file map.hpp.

template<typename K , typename T , typename C = std::less<K>, typename A = smart_allocator<std::pair<const K,T> >>
itemT proton::map_< K, T, C, A >::popitem ( )
inline

pop the first item.

Exceptions:
proton::errif there is no items in the map.

Definition at line 238 of file map.hpp.

References PROTON_THROW_IF.

template<typename K , typename T , typename C = std::less<K>, typename A = smart_allocator<std::pair<const K,T> >>
template<typename... D>
const T& proton::map_< K, T, C, A >::setdefault ( const K &  key,
D &&...  dft 
)
inline

If key exists, return its value.

If not, insert key with a value of default and return default.

Definition at line 250 of file map.hpp.


The documentation for this class was generated from the following file: