COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
07/09/04 09:33:12 (20 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@949
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/deba/vector_map_factory.h

    r627 r698  
    44#include <vector>
    55
    6 #include "map_registry.h"
    7 
    86namespace hugo {
    97       
    108  template <typename MapRegistry>
    11   class VectorMapFactory {
    12   public:
     9    class VectorMapFactory {
     10    public:
    1311               
    1412    typedef typename MapRegistry::Graph Graph;
     
    1715
    1816    typedef typename MapRegistry::MapBase MapBase;
     17
    1918               
    2019    template <typename V>
     
    2322      typedef V Value;
    2423       
     24      typedef std::vector<Value> Container;
    2525      Map() {}
    2626                       
     
    3535       
    3636       
    37       Value& operator[](const Key& key) {
     37      typename Container::reference operator[](const Key& key) {
    3838        int id = graph->id(key);
    3939        return container[id];
    4040      }
    4141               
    42       const Value& operator[](const Key& key) const {
     42      typename Container::const_reference operator[](const Key& key) const {
    4343        int id = graph->id(key);
    4444        return container[id];
    4545      }
    4646       
    47       const Value& get(const Key& key) const {
    48         int id = graph->id(key);
    49         return container[id];
    50       }
    51                
    5247      void set(const Key& key, const Value& val) {
    5348        int id = graph->id(key);
     
    6459      void erase(const Key& key) {}
    6560       
     61      class const_iterator {
     62
     63      private:
     64     
     65      };
     66
     67      class iterator {
     68      public:
     69        iterator() {}
     70     
     71        std::pair<const Key&, Value&> operator*() {
     72          return std::pair<const Key&, Value&>(static_cast<Key&>(it), map[it]);
     73        }
     74
     75        iterator& operator++() { ++it; return *this; }
     76        iterator operator++(int) { iterator tmp(it); ++it; return tmp; }
     77      private:
     78        Map& map;
     79        KeyIt it;
     80      };
     81
    6682      private:
    6783      typedef std::vector<Value> Container;
    6884               
    6985      Container container;
     86
     87
    7088    };
     89
     90   
     91
    7192               
    7293  };
Note: See TracChangeset for help on using the changeset viewer.