time_stamper.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <HTML>
  2. <!--
  3. Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <Head>
  9. <Title>Boost Graph Library: time_stamper</Title>
  10. <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
  11. ALINK="#ff0000">
  12. <IMG SRC="../../../boost.png"
  13. ALT="C++ Boost" width="277" height="86">
  14. <BR Clear>
  15. <H1>
  16. <pre>
  17. time_stamper&lt;TimeMap, TimeT, EventTag&gt;
  18. </pre>
  19. </H1>
  20. This is an <a href="./EventVisitor.html">EventVisitor</a> that can be
  21. used to &quot;stamp&quot; a time at some event-point within an
  22. algorithm. An example of this is recording the discover or finish time
  23. of a vertex during a graph search.
  24. <p>
  25. <tt>time_stamper</tt> can be used with graph algorithms by
  26. wrapping it with the algorithm specific adaptor, such as <a
  27. href="./bfs_visitor.html"><tt>bfs_visitor</tt></a> and <a
  28. href="./dfs_visitor.html"><tt>dfs_visitor</tt></a>. Also, this event
  29. visitor can be combined with other event visitors using
  30. <tt>std::pair</tt> to form an EventVisitorList.
  31. <h3>Example</h3>
  32. The following example shows the usage of the <tt>time_stamper</tt>.
  33. <pre>
  34. std::vector<default_color_type> color(num_vertices(G));
  35. std::vector<size_type> dtime(num_vertices(G));
  36. std::vector<size_type> ftime(num_vertices(G));
  37. int time = 0;
  38. boost::breadth_first_search
  39. (G, vertex(s, G), make_bfs_visitor(
  40. std::make_pair(stamp_times(dtime.begin(), time, on_discover_vertex()),
  41. stamp_times(ftime.begin(), time, on_finish_vertex()))),
  42. color.begin());
  43. </pre>
  44. <h3>Model of</h3>
  45. <a href="./EventVisitor.html">EventVisitor</a>
  46. <H3>Where Defined</H3>
  47. <P>
  48. <a href="../../../boost/graph/visitors.hpp">
  49. <TT>boost/graph/visitors.hpp</TT></a>
  50. <H3>Template Parameters</H3>
  51. <P>
  52. <TABLE border>
  53. <TR>
  54. <th>Parameter</th><th>Description</th><th>Default</th>
  55. </tr>
  56. <TR><TD><TT>TimeMap</TT></TD>
  57. <TD>
  58. A <a
  59. href="../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap</a>
  60. where the <tt>key_type</tt> is the vertex descriptor type or edge
  61. descriptor of the graph (depending on the kind of event tag) and
  62. where the <tt>TimeT</tt> type is convertible to the
  63. <tt>value_type</tt> of the time property map.
  64. </TD>
  65. <TD>&nbsp;</TD>
  66. </TR>
  67. <TR><TD><TT>TimeT</TT></TD>
  68. <TD>
  69. The type for the time counter which should be convertible to the
  70. <tt>value_type</tt> of the time property map
  71. </TD>
  72. <TD>&nbsp;</TD>
  73. </TR>
  74. <TR><TD><TT>EventTag</TT></TD>
  75. <TD>
  76. The tag to specify when the <tt>time_stamper</tt> should be
  77. applied during the graph algorithm.
  78. </TD>
  79. <TD>&nbsp;</TD>
  80. </TR>
  81. </table>
  82. <H2>Associated Types</H2>
  83. <table border>
  84. <tr>
  85. <th>Type</th><th>Description</th>
  86. </tr>
  87. <tr>
  88. <td><tt>time_stamper::event_filter</tt></td>
  89. <td>
  90. This will be the same type as the template parameter <tt>EventTag</tt>.
  91. </td>
  92. </tr>
  93. </table>
  94. <h3>Member Functions</h3>
  95. <p>
  96. <table border>
  97. <tr>
  98. <th>Member</th><th>Description</th>
  99. </tr>
  100. <tr>
  101. <td><tt>
  102. time_stamper(TimeMap time_pa, TimeT& t);
  103. </tt></td>
  104. <td>
  105. Construct a time stamper object with time property map
  106. <tt>time_pa</tt> and time counter <tt>t</tt>.
  107. </td>
  108. </tr>
  109. <tr>
  110. <td><tt>
  111. template &lt;class X, class Graph&gt;<br>
  112. void operator()(X x, const Graph& g);
  113. </tt></td>
  114. <td>
  115. This increments the time count and &quot;stamps&quot; the time:<br>
  116. <tt>put(time_pa, x, ++t);</tt>
  117. </td>
  118. </tr>
  119. </table>
  120. <h3>Non-Member Functions</h3>
  121. <table border>
  122. <tr>
  123. <th>Function</th><th>Description</th>
  124. </tr>
  125. <tr><td><tt>
  126. template &lt;class TimeMap, class TimeT, class Tag&gt;<br>
  127. time_stamper&lt;TimeMap, TimeT, Tag&gt;<br>
  128. stamp_times(TimeMap pa, TimeT& t, Tag);
  129. </tt></td><td>
  130. A convenient way to create a <tt>time_stamper</tt>.
  131. </td></tr>
  132. </table>
  133. <h3>See Also</h3>
  134. <a href="./visitor_concepts.html">Visitor concepts</a>
  135. <p>
  136. The following are other event visitors: <a
  137. <a href="./distance_recorder.html"><tt>distance_recorder</tt></a>,
  138. <a href="./time_stamper.html"><tt>time_stamper</tt></a>,
  139. and <a href="./property_writer.html"><tt>property_writer</tt></a>.
  140. <br>
  141. <HR>
  142. <TABLE>
  143. <TR valign=top>
  144. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  145. <A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>,
  146. Indiana University (<A
  147. HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
  148. <A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
  149. <A HREF="https://homes.cs.washington.edu/~al75">Andrew Lumsdaine</A>,
  150. Indiana University (<A
  151. HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
  152. </TD></TR></TABLE>
  153. </BODY>
  154. </HTML>
  155. <!-- LocalWords: TimeMap TimeT EventTag EventVisitor bfs dfs EventVisitorList
  156. -->
  157. <!-- LocalWords: cpp num dtime ftime int WritablePropertyMap map
  158. -->
  159. <!-- LocalWords: const Siek Univ Quan Lumsdaine
  160. -->