COIN-OR::LEMON - Graph Library

Changeset 2331:e389580e3348 in lemon-0.x


Ignore:
Timestamp:
12/18/06 15:35:33 (13 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3117
Message:

Easier inverse than m.inverse()[a] => m(a)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/graph_utils.h

    r2329 r2331  
    15831583    /// \brief Constructor.
    15841584    ///
    1585     /// Constructor for creating id map.
     1585    /// Constructor of the map.
    15861586    explicit IdMap(const Graph& _graph) : graph(&_graph) {}
    15871587
    15881588    /// \brief Gives back the \e id of the item.
    15891589    ///
    1590     /// Gives back the immutable and unique \e id of the map.
     1590    /// Gives back the immutable and unique \e id of the item.
    15911591    int operator[](const Item& item) const { return graph->id(item);}
    15921592
     1593    /// \brief Gives back the item by its id.
     1594    ///
     1595    /// Gives back the item by its id.
     1596    Item operator()(int id) { return graph->fromId(id, Item()); }
    15931597
    15941598  private:
     
    16191623      ///
    16201624      Item operator[](int id) const { return graph->fromId(id, Item());}
     1625
    16211626    private:
    16221627      const Graph* graph;
     
    17451750    }
    17461751
     1752    /// \brief Gives back the item by its value.
     1753    ///
     1754    /// Gives back the item by its value.
     1755    Key operator()(const Value& key) const {
     1756      typename Container::const_iterator it = invMap.find(key);
     1757      return it != invMap.end() ? it->second : INVALID;
     1758    }
     1759
    17471760  protected:
    17481761
     
    18081821      /// what was last assigned to the value.
    18091822      Value operator[](const Key& key) const {
    1810         typename Container::const_iterator it = inverted.invMap.find(key);
    1811         return it->second;
     1823        return inverted(key);
    18121824      }
    18131825     
     
    19671979      return Map::operator[](item);
    19681980    }
     1981
     1982    /// \brief Gives back the item by its descriptor.
     1983    ///
     1984    /// Gives back th item by its descriptor.
     1985    Item operator()(int id) const {
     1986      return invMap[id];
     1987    }
    19691988   
    19701989  private:
     
    19962015      /// that the descriptor belongs to currently.
    19972016      Value operator[](const Key& key) const {
    1998         return inverted.invMap[key];
     2017        return inverted(key);
    19992018      }
    20002019
     
    20032022      /// Returns the size of the map.
    20042023      unsigned int size() const {
    2005         return inverted.invMap.size();
     2024        return inverted.size();
    20062025      }
    20072026     
Note: See TracChangeset for help on using the changeset viewer.