COIN-OR::LEMON - Graph Library

Changeset 1205:d3dcc49e6403 in lemon for lemon


Ignore:
Timestamp:
02/28/13 17:13:14 (7 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Use output iterator instead of a container (#386)
in tourNodes() functions of TSP algorithms

Location:
lemon
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • lemon/christofides_tsp.h

    r1204 r1205  
    210210      ///
    211211      /// This function copies the node sequence of the found tour into
    212       /// the given standard container.
    213       ///
    214       /// \pre run() must be called before using this function.
    215       template <typename Container>
    216       void tourNodes(Container &container) const {
    217         container.assign(_path.begin(), _path.end());
     212      /// an STL container through the given output iterator. The
     213      /// <tt>value_type</tt> of the container must be <tt>FullGraph::Node</tt>.
     214      /// For example,
     215      /// \code
     216      /// std::vector<FullGraph::Node> nodes(countNodes(graph));
     217      /// tsp.tourNodes(nodes.begin());
     218      /// \endcode
     219      /// or
     220      /// \code
     221      /// std::list<FullGraph::Node> nodes;
     222      /// tsp.tourNodes(std::back_inserter(nodes));
     223      /// \endcode
     224      ///
     225      /// \pre run() must be called before using this function.
     226      template <typename Iterator>
     227      void tourNodes(Iterator out) const {
     228        std::copy(_path.begin(), _path.end(), out);
    218229      }
    219230     
  • lemon/greedy_tsp.h

    r1204 r1205  
    207207      ///
    208208      /// This function copies the node sequence of the found tour into
    209       /// the given standard container.
    210       ///
    211       /// \pre run() must be called before using this function.
    212       template <typename Container>
    213       void tourNodes(Container &container) const {
    214         container.assign(_path.begin(), _path.end());
     209      /// an STL container through the given output iterator. The
     210      /// <tt>value_type</tt> of the container must be <tt>FullGraph::Node</tt>.
     211      /// For example,
     212      /// \code
     213      /// std::vector<FullGraph::Node> nodes(countNodes(graph));
     214      /// tsp.tourNodes(nodes.begin());
     215      /// \endcode
     216      /// or
     217      /// \code
     218      /// std::list<FullGraph::Node> nodes;
     219      /// tsp.tourNodes(std::back_inserter(nodes));
     220      /// \endcode
     221      ///
     222      /// \pre run() must be called before using this function.
     223      template <typename Iterator>
     224      void tourNodes(Iterator out) const {
     225        std::copy(_path.begin(), _path.end(), out);
    215226      }
    216227
  • lemon/insertion_tsp.h

    r1204 r1205  
    204204      ///
    205205      /// This function copies the node sequence of the found tour into
    206       /// the given standard container.
     206      /// an STL container through the given output iterator. The
     207      /// <tt>value_type</tt> of the container must be <tt>FullGraph::Node</tt>.
     208      /// For example,
     209      /// \code
     210      /// std::vector<FullGraph::Node> nodes(countNodes(graph));
     211      /// tsp.tourNodes(nodes.begin());
     212      /// \endcode
     213      /// or
     214      /// \code
     215      /// std::list<FullGraph::Node> nodes;
     216      /// tsp.tourNodes(std::back_inserter(nodes));
     217      /// \endcode
    207218      ///
    208219      /// \pre run() must be called before using this function.
    209       template <typename Container>
    210       void tourNodes(Container &container) const {
    211         container.assign(_tour.begin(), _tour.end());
     220      template <typename Iterator>
     221      void tourNodes(Iterator out) const {
     222        std::copy(_tour.begin(), _tour.end(), out);
    212223      }
    213224
  • lemon/nearest_neighbor_tsp.h

    r1204 r1205  
    194194      ///
    195195      /// This function copies the node sequence of the found tour into
    196       /// the given standard container.
    197       ///
    198       /// \pre run() must be called before using this function.
    199       template <typename Container>
    200       void tourNodes(Container &container) const {
    201         container.assign(_path.begin(), _path.end());
     196      /// an STL container through the given output iterator. The
     197      /// <tt>value_type</tt> of the container must be <tt>FullGraph::Node</tt>.
     198      /// For example,
     199      /// \code
     200      /// std::vector<FullGraph::Node> nodes(countNodes(graph));
     201      /// tsp.tourNodes(nodes.begin());
     202      /// \endcode
     203      /// or
     204      /// \code
     205      /// std::list<FullGraph::Node> nodes;
     206      /// tsp.tourNodes(std::back_inserter(nodes));
     207      /// \endcode
     208      ///
     209      /// \pre run() must be called before using this function.
     210      template <typename Iterator>
     211      void tourNodes(Iterator out) const {
     212        std::copy(_path.begin(), _path.end(), out);
    202213      }
    203214
  • lemon/opt2_tsp.h

    r1204 r1205  
    231231      ///
    232232      /// This function copies the node sequence of the found tour into
    233       /// the given standard container.
     233      /// an STL container through the given output iterator. The
     234      /// <tt>value_type</tt> of the container must be <tt>FullGraph::Node</tt>.
     235      /// For example,
     236      /// \code
     237      /// std::vector<FullGraph::Node> nodes(countNodes(graph));
     238      /// tsp.tourNodes(nodes.begin());
     239      /// \endcode
     240      /// or
     241      /// \code
     242      /// std::list<FullGraph::Node> nodes;
     243      /// tsp.tourNodes(std::back_inserter(nodes));
     244      /// \endcode
    234245      ///
    235246      /// \pre run() must be called before using this function.
    236       template <typename Container>
    237       void tourNodes(Container &container) const {
    238         container.assign(_path.begin(), _path.end());
     247      template <typename Iterator>
     248      void tourNodes(Iterator out) const {
     249        std::copy(_path.begin(), _path.end(), out);
    239250      }
    240251
Note: See TracChangeset for help on using the changeset viewer.