if you have a nuclear power plant and wanna compute small magic squares, then let's do it
5 #include <lemon/bin_heap.h>
12 // Egy binaris kupac, ami stringekhez rendelt double ertekeket tarol,
13 // azaz mindig az a string van a tetejen, amihez a legkisebb szam tartozik.
14 // A kupac egy string_int_map tipusu property_map segitsegevel tarolja
15 // a stringek aktualis helyet sajatmagan belul.
16 // Egy olyan stringhez, ami meg nincsen a kupac -1 -et kell rendelnunk.
17 typedef BinHeap<string, double, string_int_map> StrDoubleHeap;
19 class string_int_map : public map<string,int> {
20 typedef map<string,int> parent;
22 int get(const string &s) {
23 // Bocs, ez igy gaaaany, de nem volt kedvem utananezni, hogy
24 // hogy is mukodik ez a map :)
26 parent::operator[](s) = StrDoubleHeap::PRE_HEAP;
28 return parent::operator[](s);
30 int operator[](const string &s) {
33 void set(const string &s, int i) {
34 parent::operator[](s) = i;
44 cout << "testing string_int_map default value:\n";
45 cout << " sim.get(\"alma\"): " << sim.get("alma") << endl;
46 cout << " sim[\"alma\"]: " << sim["alma"] << endl;
48 cout << "creating the heap\n";
49 StrDoubleHeap heap(sim);
51 cout << "heap.push(\"alma\", 15);\n";
52 heap.push("alma", 15);
54 cout << "heap.set(\"korte\", 3.4);\n";
55 heap.set("korte", 3.4);
57 cout << "heap[\"alma\"] = "
61 cout << "heap.top() = "
62 << heap.top() << endl;
63 cout << "heap.prio() = "
64 << heap.prio() << endl;
66 cout << "heap.decrease(\"alma\", 1.2);\n";
67 heap.set("alma", 1.2);
69 cout << "heap.top() = "
70 << heap.top() << endl;
71 cout << "heap.prio() = "
72 << heap.prio() << endl;
74 cout << "heap.set(\"alma\", 22);\n";
77 cout << "heap.top() = "
78 << heap.top() << endl;
79 cout << "heap.prio() = "
80 << heap.prio() << endl;
82 cout << "heap.size() = "
83 << heap.size() << endl;
84 cout << "heap.pop();\n";
87 cout << "heap.top() = "
88 << heap.top() << endl;
89 cout << "heap.prio() = "
90 << heap.prio() << endl;
92 cout << "heap.state(\"szilva\") = "
93 << heap.state("szilva") << endl;
94 cout << "heap.set(\"szilva\", 0.5);\n";
95 heap.set("szilva", 0.5);
96 cout << "heap.state(\"szilva\") = "
97 << heap.state("szilva") << endl;
98 cout << "heap.top() = "
99 << heap.top() << endl;
100 cout << "heap.pop();\n";
102 cout << "heap.state(\"szilva\") = "
103 << heap.state("szilva") << endl;
105 cout << "heap.size() = "
106 << heap.size() << endl;
107 cout << "heap.pop();\n";
110 cout << "heap.size() = "
111 << heap.size() << endl;
112 cout << "heap.empty() = "
113 << (heap.empty()?"true":"false") << endl;