Changeset 214:44f01e580f16 in lemon-0.x for src
- Timestamp:
- 03/20/04 14:48:04 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@309
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/include/bin_heap.hh
r172 r214 109 109 static int parent(int i) { return (i-1)/2; } 110 110 static int second_child(int i) { return 2*i+2; } 111 bool less(const PairType &p1, const PairType &p2) {111 bool less(const PairType &p1, const PairType &p2) const { 112 112 return comp(p1.second, p2.second); 113 113 } … … 157 157 } 158 158 159 constPrio get(const Item &i) const {159 Prio get(const Item &i) const { 160 160 int idx = iim.get(i); 161 161 return data[idx].second; 162 } 163 Prio operator[](const Item &i) const { 164 return get(i); 162 165 } 163 166 void set(const Item &i, const Prio &p) { -
src/work/bin_heap_demo.cc
r172 r214 17 17 18 18 class string_int_map : public map<string,int> { 19 typedef map<string,int> parent; 19 20 public: 20 21 int get(const string &s) { … … 22 23 // hogy is mukodik ez a map :) 23 24 if( count(s) == 0 ) { 24 operator[](s) = StrDoubleHeap::PRE_HEAP;25 parent::operator[](s) = StrDoubleHeap::PRE_HEAP; 25 26 } 26 return operator[](s); 27 return parent::operator[](s); 28 } 29 int operator[](const string &s) { 30 return get(s); 27 31 } 28 32 void set(const string &s, int i) { 29 operator[](s) = i;33 parent::operator[](s) = i; 30 34 } 31 35 }; … … 38 42 39 43 cout << "testing string_int_map default value:\n"; 40 cout << " alma: " << sim.get("alma") << endl; 44 cout << " sim.get(\"alma\"): " << sim.get("alma") << endl; 45 cout << " sim[\"alma\"]: " << sim["alma"] << endl; 41 46 42 47 cout << "creating the heap\n"; … … 51 56 cout << "heap.get(\"alma\") = " 52 57 << heap.get("alma") 58 << endl; 59 cout << "heap[\"alma\"] = " 60 << heap["alma"] 53 61 << endl; 54 62
Note: See TracChangeset
for help on using the changeset viewer.