Two-Dimensional DictionariesThe data type Two-dimensional dictionaries are closely related to the data type Additionally to the normal dictionary operations, the data type ExampleThe following program shows how to used2_dictionary with keys
of type int and information of type string.
#include <LEDA/geo/d2_dictionary.h>
#include <LEDA/core/string.h>
using namespace leda;
int main()
{
d2_dictionary<int,int,string> D2;
D2.insert(85,41,"new york");
D2.insert(119,34,"los angeles");
D2.insert(71,47,"quebec");
D2.insert(16,48,"vienna");
std::cout << "Cities in d2_dictionary:\n";
list<dic2_item> L=D2.all_items();
dic2_item it;
forall(it,L) {
std::cout << "(" << D2.key1(it) << "," << D2.key2(it)
<< ")\t\t" << D2.inf(it) << std::endl;
}
std::cout << "\nCities within (0,100,0,100):\n";
list<dic2_item> L2=D2.range_search(0,100,0,100);
forall(it,L2) {
std::cout << "(" << D2.key1(it) << "," << D2.key2(it)
<< ")\t\t" << D2.inf(it) << std::endl;
}
return 0;
}
|
See also:Associating Information with Geometric Objects Manual Entries: |