Changeset 274:28728f3945c5 in lemon0.x for src
 Timestamp:
 04/01/04 23:06:53 (20 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@386
 Location:
 src
 Files:

 1 deleted
 2 edited
Legend:
 Unmodified
 Added
 Removed

src/include/bin_heap.h
r258 r274 1 // * C++ * // 2 1 3 /* FIXME: Copyright ... 2 4 * … … 60 62 #define BIN_HEAP_HH 61 63 64 ///\file 65 ///\brief Binary Heap implementation. 66 62 67 #include <vector> 63 68 #include <utility> … … 66 71 namespace hugo { 67 72 73 /// A Binary Heap implementation. 68 74 template <typename Item, typename Prio, typename ItemIntMap, 69 75 typename Compare = std::less<Prio> > … … 86 92 * PRE_HEAP (1) to any element to be put in the heap... 87 93 */ 94 ///\todo it is used nowhere 95 /// 88 96 enum state_enum { 89 97 IN_HEAP = 0, … … 141 149 142 150 Item top() const { 143 // FIXME: test size>0 ?144 151 return data[0].first; 145 152 } 146 Prio topPrio() const {147 // FIXME: test size>0 ?153 /// Returns the prio of the top element of the heap. 154 Prio prio() const { 148 155 return data[0].second; 149 156 } … … 157 164 } 158 165 159 Prio get(const Item &i) const {166 Prio operator[](const Item &i) const { 160 167 int idx = iim[i]; 161 168 return data[idx].second; 162 169 } 163 Prio operator[](const Item &i) const { 164 return get(i); 165 } 170 166 171 void set(const Item &i, const Prio &p) { 167 172 int idx = iim[i]; 
src/work/bin_heap_demo.cc
r258 r274 54 54 heap.set("korte", 3.4); 55 55 56 cout << "heap.get(\"alma\") = "57 << heap.get("alma")58 << endl;59 56 cout << "heap[\"alma\"] = " 60 57 << heap["alma"] … … 63 60 cout << "heap.top() = " 64 61 << heap.top() << endl; 65 cout << "heap. topPrio() = "66 << heap. topPrio() << endl;62 cout << "heap.prio() = " 63 << heap.prio() << endl; 67 64 68 65 cout << "heap.decrease(\"alma\", 1.2);\n"; … … 71 68 cout << "heap.top() = " 72 69 << heap.top() << endl; 73 cout << "heap. topPrio() = "74 << heap. topPrio() << endl;70 cout << "heap.prio() = " 71 << heap.prio() << endl; 75 72 76 73 cout << "heap.set(\"alma\", 22);\n"; … … 79 76 cout << "heap.top() = " 80 77 << heap.top() << endl; 81 cout << "heap. topPrio() = "82 << heap. topPrio() << endl;78 cout << "heap.prio() = " 79 << heap.prio() << endl; 83 80 84 81 cout << "heap.size() = " … … 89 86 cout << "heap.top() = " 90 87 << heap.top() << endl; 91 cout << "heap. topPrio() = "92 << heap. topPrio() << endl;88 cout << "heap.prio() = " 89 << heap.prio() << endl; 93 90 94 91 cout << "heap.state(\"szilva\") = "
Note: See TracChangeset
for help on using the changeset viewer.