7 #ifndef ALPS_PARAMS_DICTIONARY_HPP_e15039548f43464996cad06f9c8a3220 8 #define ALPS_PARAMS_DICTIONARY_HPP_e15039548f43464996cad06f9c8a3220 10 #include <alps/config.hpp> 23 typedef std::map<std::string, value_type> map_type;
30 const_iterator
begin()
const {
return map_.begin(); }
33 const_iterator
end()
const {
return map_.end(); }
39 bool empty()
const {
return map_.empty(); }
42 std::size_t
size()
const {
return map_.size(); }
45 void erase(
const std::string& key) { map_.erase(key); }
48 value_type&
operator[](
const std::string& key);
51 const value_type&
operator[](
const std::string& key)
const;
54 const_iterator
find(
const std::string& key)
const {
55 return map_.find(key);
60 map_type::const_iterator find_nonempty_(
const std::string& key)
const;
65 bool exists(
const std::string& key)
const {
66 return find_nonempty_(key)!=map_.end();
71 bool exists(
const std::string& key)
const {
72 map_type::const_iterator it=find_nonempty_(key);
73 return it!=map_.end() && (it->second).isType<T>();
109 template <
typename F>
119 template <
typename F>
bool empty() const
True if the cdictionary does not contain elements (even empty ones)
const_iterator begin() const
Const-iterator to the beginning of the contained map.
void broadcast(C const &c, P &p, int r=0)
std::size_t size() const
Size of the dictionary (including empty elements)
void swap(params &p1, params &p2)
bool operator==(const dictionary &lhs, const dictionary &rhs)
Encapsulation of an MPI communicator and some communicator-related operations.
F::result_type apply_visitor(F &visitor, dictionary::const_iterator it)
Const-access visitor to a value by an iterator.
F::result_type apply_visitor(const F &visitor, dictionary::const_iterator it)
Const-access visitor to a value by an iterator.
bool equals(const dictionary &rhs) const
Compare two dictionaries (true if all entries are of the same type and value)
virtual ~dictionary()
Virtual destructor to make dictionary inheritable.
friend std::ostream & operator<<(std::ostream &, const dictionary &)
void erase(const std::string &key)
Erase an element if it exists.
void load(alps::hdf5::archive &ar)
Load the dictionary from an archive.
void save(alps::hdf5::archive &ar) const
Save the dictionary to an archive.
friend void swap(dictionary &d1, dictionary &d2)
Swap the dictionaries.
value_type & operator[](const std::string &key)
Access with intent to assign.
bool exists(const std::string &key) const
Check if a key exists and has a value of a particular type (without creating the key) ...
const_iterator end() const
Const-iterator to the end of the contained map.
bool exists(const std::string &key) const
Check if a key exists and has a value (without creating the key)
const_iterator find(const std::string &key) const
Obtain read-only iterator to a name.
map_type::const_iterator const_iterator
bool operator!=(const dictionary &lhs, const dictionary &rhs)