Dictionary ArraysThe data type d_array can be used to store objects of an arbitrary type I together with an associated key of a linearly ordered type K (int, string,ExampleThe following program implements a very simple english-german dictionary using ad_array . It enters three words and then outputs the contents
of the dictionary.
#include <LEDA/core/d_array.h> #include <LEDA/core/string.h> using namespace leda; int main() { d_array<string,string> D; //objects of type string, keys of type string D["hello"]="hallo";D["world"]="Welt";D["book"]="Buch"; string s; forall_defined(s,D) std::cout << s << " " << D[s] << std::endl; return 0; } Strengths
Disadvantages
Tips
|
See also:Other data types with key of linearly ordered type: Data type with key of type pointer, item, or int: Maps Data type with key of hashed type: Hashing Arrays Manual Entries: |