11 // Egy binaris kupac, ami stringekhez rendelt double ertekeket tarol,
12 // azaz mindig az a string van a tetejen, amihez a legkisebb szam tartozik.
13 // A kupac egy string_int_map tipusu property_map segitsegevel tarolja
14 // a stringek aktualis helyet sajatmagan belul.
15 // Egy olyan stringhez, ami meg nincsen a kupac -1 -et kell rendelnunk.
16 typedef BinHeap<string, double, string_int_map> StrDoubleHeap;
18 class string_int_map : public map<string,int> {
20 int get(const string &s) {
21 // Bocs, ez igy gaaaany, de nem volt kedvem utananezni, hogy
22 // hogy is mukodik ez a map :)
24 operator[](s) = StrDoubleHeap::PRE_HEAP;
28 void put(const string &s, int i) {
39 cout << "testing string_int_map default value:\n";
40 cout << " alma: " << sim.get("alma") << endl;
42 cout << "creating the heap\n";
43 StrDoubleHeap heap(sim);
45 cout << "heap.push(\"alma\", 15);\n";
46 heap.push("alma", 15);
48 cout << "heap.put(\"korte\", 3.4);\n";
49 heap.put("korte", 3.4);
51 cout << "heap.get(\"alma\") = "
55 cout << "heap.top() = "
56 << heap.top() << endl;
57 cout << "heap.topValue() = "
58 << heap.topValue() << endl;
60 cout << "heap.decrease(\"alma\", 1.2);\n";
61 heap.put("alma", 1.2);
63 cout << "heap.top() = "
64 << heap.top() << endl;
65 cout << "heap.topValue() = "
66 << heap.topValue() << endl;
68 cout << "heap.put(\"alma\", 22);\n";
71 cout << "heap.top() = "
72 << heap.top() << endl;
73 cout << "heap.topValue() = "
74 << heap.topValue() << endl;
76 cout << "heap.size() = "
77 << heap.size() << endl;
78 cout << "heap.pop();\n";
81 cout << "heap.top() = "
82 << heap.top() << endl;
83 cout << "heap.topValue() = "
84 << heap.topValue() << endl;
86 cout << "heap.state(\"szilva\") = "
87 << heap.state("szilva") << endl;
88 cout << "heap.put(\"szilva\", 0.5);\n";
89 heap.put("szilva", 0.5);
90 cout << "heap.state(\"szilva\") = "
91 << heap.state("szilva") << endl;
92 cout << "heap.top() = "
93 << heap.top() << endl;
94 cout << "heap.pop();\n";
96 cout << "heap.state(\"szilva\") = "
97 << heap.state("szilva") << endl;
99 cout << "heap.size() = "
100 << heap.size() << endl;
101 cout << "heap.pop();\n";
104 cout << "heap.size() = "
105 << heap.size() << endl;
106 cout << "heap.empty() = "
107 << (heap.empty()?"true":"false") << endl;