COIN-OR::LEMON - Graph Library

Changeset 214:44f01e580f16 in lemon-0.x for src


Ignore:
Timestamp:
03/20/04 14:48:04 (21 years ago)
Author:
Mihaly Barasz
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@309
Message:

Feluton az uj map stilus fele.
Nehany const javitas.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/include/bin_heap.hh

    r172 r214  
    109109    static int parent(int i) { return (i-1)/2; }
    110110    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 {
    112112      return comp(p1.second, p2.second);
    113113    }
     
    157157    }
    158158
    159     const Prio get(const Item &i) const {
     159    Prio get(const Item &i) const {
    160160      int idx = iim.get(i);
    161161      return data[idx].second;
     162    }
     163    Prio operator[](const Item &i) const {
     164      return get(i);
    162165    }
    163166    void set(const Item &i, const Prio &p) {
  • src/work/bin_heap_demo.cc

    r172 r214  
    1717
    1818class string_int_map : public map<string,int> {
     19  typedef map<string,int> parent;
    1920public:
    2021  int get(const string &s) {
     
    2223    // hogy is mukodik ez a map :)
    2324    if( count(s) == 0 ) {
    24       operator[](s) = StrDoubleHeap::PRE_HEAP;
     25      parent::operator[](s) = StrDoubleHeap::PRE_HEAP;
    2526    }
    26     return operator[](s);
     27    return parent::operator[](s);
     28  }
     29  int operator[](const string &s) {
     30    return get(s);
    2731  }
    2832  void set(const string &s, int i) {
    29       operator[](s) = i;
     33      parent::operator[](s) = i;
    3034  }
    3135};
     
    3842 
    3943  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;
    4146
    4247  cout << "creating the heap\n";
     
    5156  cout << "heap.get(\"alma\") = "
    5257       << heap.get("alma")
     58       << endl;
     59  cout << "heap[\"alma\"] = "
     60       << heap["alma"]
    5361       << endl;
    5462
Note: See TracChangeset for help on using the changeset viewer.