|
ASL
|
An associative container linking keys of type K with values of type T.
By default, keys and values are Strings.
Maps can be initialized with shorthand syntax (this is useful in Http::get() to specify HTTP request headers):
of with braces, in C++11:
And iterated with the foreach2 macro:
In C++11 you can use range-based for loops:
And in C++17:
#include <Map.h>
Inherited by Dic< asl::String >, Dic< asl::Array< asl::String > >, Dic< T *(*)()>, Dic< asl::Dic >, and Dic< T >.
Public Member Functions | |
| template<class K2 , class T2 > | |
| Map (const Map< K2, T2 > &b) | |
| Constructs a Map from a Map of different key or value types. | |
| int | length () const |
| Returns the number of elements in this map. | |
| void | clear () |
| Removes all elements. | |
| Map & | dup () |
| Detaches this Map from other ones possibly sharing it. | |
| Map | clone () const |
| Returns an independent copy of this map. | |
| bool | has (const K &key) const |
Returns true if an element with key key exists. | |
| const T * | find (const K &key) const |
Returns a pointer to the element with key key or a null pointer if it is not found. | |
| Array< K > | keys () const |
| Returns an array containing all keys of this map. | |
| const T & | operator[] (const K &key) const |
| Returns a reference to the element with key key, or a static default constructed item if not found. | |
| const T & | get (const K &key, const T &def) const |
Returns the element with key key or the value def if key is not found. | |
| Map & | operator() (const K &key, const T &value) |
| Adds an element with the given key and value, useful for the short hand initializer style shown in the class overview. | |
| bool | remove (const K &key) |
| Removes the element named key. | |
| void | add (const Map &d) |
| Adds all elements from dictionary d to this. | |
| Enumerator | all () const |
| Returns an enumerator for this map. | |
| String | join (const String &s1, const String &s2) const |
Joins the contents of a Dic<> into a string, using s1 as element separator (often a comma) and s2 as key-value separator (usually an '='). | |