COIN-OR::LEMON - Graph Library

Changeset 1205:d3dcc49e6403 in lemon for lemon/greedy_tsp.h


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.