[Lemon-commits] Peter Kovacs: Remove maps having unclear purpose...

Lemon HG hg at lemon.cs.elte.hu
Sun Mar 16 08:35:44 CET 2008


details:   http://lemon.cs.elte.hu/hg/lemon/rev/7ff1c348ae0c
changeset: 81:7ff1c348ae0c
user:      Peter Kovacs <kpeter [at] inf.elte.hu>
date:      Sat Mar 15 21:24:43 2008 +0100
description:
	Remove maps having unclear purposes or little use

	- WrapMap (SimpleMap)
	- WrapWriteMap (SimpleWriteMap)
	- StoreBoolMap
	- BackInserterBoolMap
	- FrontInserterBoolMap
	- InserterBoolMap
	- FillBoolMap
	- SettingOrderBoolMap

diffstat:

1 file changed, 448 deletions(-)
lemon/maps.h |  448 ----------------------------------------------------------

diffs (truncated from 465 to 300 lines):

diff -r 15968e25ca08 -r 7ff1c348ae0c lemon/maps.h
--- a/lemon/maps.h	Sat Mar 15 21:07:24 2008 +0100
+++ b/lemon/maps.h	Sat Mar 15 21:24:43 2008 +0100
@@ -773,78 +773,6 @@ namespace lemon {
   }
 
 
-  /// Simple wrapping of a map
-
-  /// This \ref concepts::ReadMap "read only map" returns the simple
-  /// wrapping of the given map. Sometimes the reference maps cannot be
-  /// combined with simple read maps. This map adaptor wraps the given
-  /// map to simple read map.
-  ///
-  /// The simplest way of using this map is through the wrapMap()
-  /// function.
-  ///
-  /// \sa WrapWriteMap
-  template<typename M>
-  class WrapMap : public MapBase<typename M::Key, typename M::Value> {
-    const M &_m;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    /// Constructor
-    WrapMap(const M &m) : _m(m) {}
-    /// \e
-    Value operator[](const Key &k) const { return _m[k]; }
-  };
-
-  /// Returns a \ref WrapMap class
-
-  /// This function just returns a \ref WrapMap class.
-  /// \relates WrapMap
-  template<typename M>
-  inline WrapMap<M> wrapMap(const M &map) {
-    return WrapMap<M>(map);
-  }
-
-
-  /// Simple writable wrapping of a map
-
-  /// This \ref concepts::ReadWriteMap "read-write map" returns the simple
-  /// wrapping of the given map. Sometimes the reference maps cannot be
-  /// combined with simple read-write maps. This map adaptor wraps the
-  /// given map to simple read-write map.
-  ///
-  /// The simplest way of using this map is through the wrapWriteMap()
-  /// function.
-  ///
-  /// \sa WrapMap
-  template<typename M>
-  class WrapWriteMap : public MapBase<typename M::Key, typename M::Value> {
-    M &_m;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    /// Constructor
-    WrapWriteMap(M &m) : _m(m) {}
-    /// \e
-    Value operator[](const Key &k) const { return _m[k]; }
-    /// \e
-    void set(const Key &k, const Value &c) { _m.set(k, c); }
-  };
-
-  ///Returns a \ref WrapWriteMap class
-
-  ///This function just returns a \ref WrapWriteMap class.
-  ///\relates WrapWriteMap
-  template<typename M>
-  inline WrapWriteMap<M> wrapWriteMap(M &map) {
-    return WrapWriteMap<M>(map);
-  }
-
-
   /// Sum of two maps
 
   /// This \ref concepts::ReadMap "read only map" returns the sum
@@ -1463,382 +1391,6 @@ namespace lemon {
     return NotWriteMap<M>(m);
   }
 
-
-  namespace _maps_bits {
-
-    template <typename Value>
-    struct Identity {
-      typedef Value argument_type;
-      typedef Value result_type;
-      Value operator()(const Value& val) const {
-	return val;
-      }
-    };
-
-    template <typename _Iterator, typename Enable = void>
-    struct IteratorTraits {
-      typedef typename std::iterator_traits<_Iterator>::value_type Value;
-    };
-
-    template <typename _Iterator>
-    struct IteratorTraits<_Iterator,
-      typename exists<typename _Iterator::container_type>::type>
-    {
-      typedef typename _Iterator::container_type::value_type Value;
-    };
-
-  }
-
-
-  /// \brief Writable bool map for logging each \c true assigned element
-  ///
-  /// A \ref concepts::ReadWriteMap "read-write" bool map for logging
-  /// each \c true assigned element, i.e it copies all the keys set
-  /// to \c true to the given iterator.
-  ///
-  /// \note The container of the iterator should contain space
-  /// for each element.
-  ///
-  /// The following example shows how you can write the edges found by
-  /// the \ref Prim algorithm directly to the standard output.
-  /// \code
-  ///   typedef IdMap<Graph, Edge> EdgeIdMap;
-  ///   EdgeIdMap edgeId(graph);
-  ///
-  ///   typedef MapToFunctor<EdgeIdMap> EdgeIdFunctor;
-  ///   EdgeIdFunctor edgeIdFunctor(edgeId);
-  ///
-  ///   StoreBoolMap<ostream_iterator<int>, EdgeIdFunctor>
-  ///     writerMap(ostream_iterator<int>(cout, " "), edgeIdFunctor);
-  ///
-  ///   prim(graph, cost, writerMap);
-  /// \endcode
-  ///
-  /// \sa BackInserterBoolMap
-  /// \sa FrontInserterBoolMap
-  /// \sa InserterBoolMap
-  ///
-  /// \todo Revise the name of this class and the related ones.
-  template <typename _Iterator,
-            typename _Functor =
-            _maps_bits::Identity<typename _maps_bits::
-                                 IteratorTraits<_Iterator>::Value> >
-  class StoreBoolMap {
-  public:
-    typedef _Iterator Iterator;
-
-    typedef typename _Functor::argument_type Key;
-    typedef bool Value;
-
-    typedef _Functor Functor;
-
-    /// Constructor
-    StoreBoolMap(Iterator it, const Functor& functor = Functor())
-      : _begin(it), _end(it), _functor(functor) {}
-
-    /// Gives back the given iterator set for the first key
-    Iterator begin() const {
-      return _begin;
-    }
-
-    /// Gives back the the 'after the last' iterator
-    Iterator end() const {
-      return _end;
-    }
-
-    /// The set function of the map
-    void set(const Key& key, Value value) const {
-      if (value) {
-	*_end++ = _functor(key);
-      }
-    }
-
-  private:
-    Iterator _begin;
-    mutable Iterator _end;
-    Functor _functor;
-  };
-
-  /// \brief Writable bool map for logging each \c true assigned element in
-  /// a back insertable container.
-  ///
-  /// Writable bool map for logging each \c true assigned element by pushing
-  /// them into a back insertable container.
-  /// It can be used to retrieve the items into a standard
-  /// container. The next example shows how you can store the
-  /// edges found by the Prim algorithm in a vector.
-  ///
-  /// \code
-  ///   vector<Edge> span_tree_edges;
-  ///   BackInserterBoolMap<vector<Edge> > inserter_map(span_tree_edges);
-  ///   prim(graph, cost, inserter_map);
-  /// \endcode
-  ///
-  /// \sa StoreBoolMap
-  /// \sa FrontInserterBoolMap
-  /// \sa InserterBoolMap
-  template <typename Container,
-            typename Functor =
-            _maps_bits::Identity<typename Container::value_type> >
-  class BackInserterBoolMap {
-  public:
-    typedef typename Functor::argument_type Key;
-    typedef bool Value;
-
-    /// Constructor
-    BackInserterBoolMap(Container& _container,
-                        const Functor& _functor = Functor())
-      : container(_container), functor(_functor) {}
-
-    /// The set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	container.push_back(functor(key));
-      }
-    }
-
-  private:
-    Container& container;
-    Functor functor;
-  };
-
-  /// \brief Writable bool map for logging each \c true assigned element in
-  /// a front insertable container.
-  ///
-  /// Writable bool map for logging each \c true assigned element by pushing
-  /// them into a front insertable container.
-  /// It can be used to retrieve the items into a standard
-  /// container. For example see \ref BackInserterBoolMap.
-  ///
-  /// \sa BackInserterBoolMap
-  /// \sa InserterBoolMap
-  template <typename Container,
-            typename Functor =
-            _maps_bits::Identity<typename Container::value_type> >
-  class FrontInserterBoolMap {
-  public:
-    typedef typename Functor::argument_type Key;
-    typedef bool Value;
-
-    /// Constructor
-    FrontInserterBoolMap(Container& _container,
-                         const Functor& _functor = Functor())
-      : container(_container), functor(_functor) {}
-
-    /// The set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	container.push_front(functor(key));
-      }
-    }
-
-  private:
-    Container& container;
-    Functor functor;
-  };
-
-  /// \brief Writable bool map for storing each \c true assigned element in
-  /// an insertable container.
-  ///
-  /// Writable bool map for storing each \c true assigned element in an
-  /// insertable container. It will insert all the keys set to \c true into
-  /// the container.
-  ///
-  /// For example, if you want to store the cut arcs of the strongly
-  /// connected components in a set you can use the next code:
-  ///
-  /// \code
-  ///   set<Arc> cut_arcs;
-  ///   InserterBoolMap<set<Arc> > inserter_map(cut_arcs);
-  ///   stronglyConnectedCutArcs(digraph, cost, inserter_map);
-  /// \endcode
-  ///
-  /// \sa BackInserterBoolMap
-  /// \sa FrontInserterBoolMap
-  template <typename Container,
-            typename Functor =
-            _maps_bits::Identity<typename Container::value_type> >
-  class InserterBoolMap {
-  public:
-    typedef typename Container::value_type Key;
-    typedef bool Value;
-
-    /// Constructor with specified iterator
-
-    /// Constructor with specified iterator.
-    /// \param _container The container for storing the elements.
-    /// \param _it The elements will be inserted before this iterator.
-    /// \param _functor The functor that is used when an element is stored.
-    InserterBoolMap(Container& _container, typename Container::iterator _it,
-                    const Functor& _functor = Functor())
-      : container(_container), it(_it), functor(_functor) {}
-
-    /// Constructor
-
-    /// Constructor without specified iterator.
-    /// The elements will be inserted before <tt>_container.end()</tt>.



More information about the Lemon-commits mailing list