COIN-OR::LEMON - Graph Library

Ticket #34: loggerboolmap.patch

File loggerboolmap.patch, 4.9 KB (added by Peter Kovacs, 12 years ago)
  • lemon/kruskal.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1213464855 -7200
    # Node ID d57ae6f0a335ba6ee61d0f1e4fd7f11460318268
    # Parent  579979fad316ae8b42af36ac92b98eec5d3bfb3f
    Rename StoreBoolMap to LoggerBoolMap (ticket #34).
    
    diff -r 579979fad316 -r d57ae6f0a335 lemon/kruskal.h
    a b  
    229229      typedef typename In::value_type::second_type Value;
    230230
    231231      static Value kruskal(const Graph& graph, const In& in, Out& out) {
    232         typedef StoreBoolMap<typename RemoveConst<Out>::type> Map;
     232        typedef LoggerBoolMap<typename RemoveConst<Out>::type> Map;
    233233        Map map(out);
    234234        return _kruskal_bits::kruskal(graph, in, map);
    235235      }
  • lemon/maps.h

    diff -r 579979fad316 -r d57ae6f0a335 lemon/maps.h
    a b  
    17001700  /// maps and most of them assign \c true at most once for each key.
    17011701  /// In these cases it is a natural request to store each \c true
    17021702  /// assigned elements (in order of the assignment), which can be
    1703   /// easily done with StoreBoolMap.
     1703  /// easily done with LoggerBoolMap.
    17041704  ///
    1705   /// The simplest way of using this map is through the storeBoolMap()
     1705  /// The simplest way of using this map is through the loggerBoolMap()
    17061706  /// function.
    17071707  ///
    17081708  /// \tparam It The type of the iterator.
     
    17171717  template <typename It,
    17181718            typename Ke=typename _maps_bits::IteratorTraits<It>::Value>
    17191719#endif
    1720   class StoreBoolMap {
     1720  class LoggerBoolMap {
    17211721  public:
    17221722    typedef It Iterator;
    17231723
     
    17251725    typedef bool Value;
    17261726
    17271727    /// Constructor
    1728     StoreBoolMap(Iterator it)
     1728    LoggerBoolMap(Iterator it)
    17291729      : _begin(it), _end(it) {}
    17301730
    17311731    /// Gives back the given iterator set for the first key
     
    17501750    Iterator _end;
    17511751  };
    17521752 
    1753   /// Returns a \ref StoreBoolMap class
     1753  /// Returns a \ref LoggerBoolMap class
    17541754
    1755   /// This function just returns a \ref StoreBoolMap class.
     1755  /// This function just returns a \ref LoggerBoolMap class.
    17561756  ///
    17571757  /// The most important usage of it is storing certain nodes or arcs
    17581758  /// that were marked \c true by an algorithm.
     
    17601760  /// order of Dfs algorithm, as the following examples show.
    17611761  /// \code
    17621762  ///   std::vector<Node> v;
    1763   ///   dfs(g,s).processedMap(storeBoolMap(std::back_inserter(v))).run();
     1763  ///   dfs(g,s).processedMap(loggerBoolMap(std::back_inserter(v))).run();
    17641764  /// \endcode
    17651765  /// \code
    17661766  ///   std::vector<Node> v(countNodes(g));
    1767   ///   dfs(g,s).processedMap(storeBoolMap(v.begin())).run();
     1767  ///   dfs(g,s).processedMap(loggerBoolMap(v.begin())).run();
    17681768  /// \endcode
    17691769  ///
    17701770  /// \note The container of the iterator must contain enough space
    17711771  /// for the elements or the iterator should be an inserter iterator.
    17721772  ///
    1773   /// \note StoreBoolMap is just \ref concepts::WriteMap "writable", so
     1773  /// \note LoggerBoolMap is just \ref concepts::WriteMap "writable", so
    17741774  /// it cannot be used when a readable map is needed, for example as
    1775   /// \c ReachedMap for Bfs, Dfs and Dijkstra algorithms.
     1775  /// \c ReachedMap for \ref Bfs, \ref Dfs and \ref Dijkstra algorithms.
    17761776  ///
    1777   /// \relates StoreBoolMap
     1777  /// \relates LoggerBoolMap
    17781778  template<typename Iterator>
    1779   inline StoreBoolMap<Iterator> storeBoolMap(Iterator it) {
    1780     return StoreBoolMap<Iterator>(it);
     1779  inline LoggerBoolMap<Iterator> loggerBoolMap(Iterator it) {
     1780    return LoggerBoolMap<Iterator>(it);
    17811781  }
    17821782
    17831783  /// @}
  • test/maps_test.cc

    diff -r 579979fad316 -r d57ae6f0a335 test/maps_test.cc
    a b  
    305305          "Something is wrong with EqualMap");
    306306  }
    307307 
    308   // StoreBoolMap
     308  // LoggerBoolMap
    309309  {
    310310    typedef std::vector<int> vec;
    311311    vec v1;
    312312    vec v2(10);
    313     StoreBoolMap<std::back_insert_iterator<vec> > map1(std::back_inserter(v1));
    314     StoreBoolMap<vec::iterator> map2(v2.begin());
     313    LoggerBoolMap<std::back_insert_iterator<vec> > map1(std::back_inserter(v1));
     314    LoggerBoolMap<vec::iterator> map2(v2.begin());
    315315    map1.set(10, false);
    316316    map1.set(20, true);   map2.set(20, true);
    317317    map1.set(30, false);  map2.set(40, false);
     
    319319    map1.set(60, true);   map2.set(60, true);
    320320    check(v1.size() == 3 && v2.size() == 10 &&
    321321          v1[0]==20 && v1[1]==50 && v1[2]==60 && v2[0]==20 && v2[1]==50 && v2[2]==60,
    322           "Something is wrong with StoreBoolMap");
     322          "Something is wrong with LoggerBoolMap");
    323323         
    324324    int i = 0;
    325     for ( StoreBoolMap<vec::iterator>::Iterator it = map2.begin();
     325    for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin();
    326326          it != map2.end(); ++it )
    327       check(v1[i++] == *it, "Something is wrong with StoreBoolMap");
     327      check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
    328328  }
    329329
    330330  return 0;