BidirectionalIterator.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?xml version="1.0"?>
  2. <concept name="BidirectionalIterator" category="Iterator"><!--
  3. Based on concepts from the SGI Standard Template Library documentation:
  4. Copyright (c) 1996-1999
  5. Silicon Graphics Computer Systems, Inc.
  6. Copyright (c) 1994
  7. Hewlett-Packard Company
  8. --><!--
  9. Copyright 2000-2001 University of Notre Dame du Lac.
  10. Copyright 2001-2002 Indiana University.
  11. Some concepts based on versions from the MTL draft manual and Boost Graph
  12. and Property Map documentation:
  13. Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
  14. -->
  15. <param name="Iter" role="iterator-type"/>
  16. <use-header name="iterator"/>
  17. <models-sentence>The iterator type <arg num="1"/> must be a model of <self/>.</models-sentence>
  18. <description>
  19. <para>A bidirectional iterator is an iterator that can read through a sequence
  20. of values. It can move in either direction through the sequence, and can
  21. be either mutable (data pointed to by it can be changed) or not mutable.</para>
  22. <para>An iterator represents a position in a sequence. Therefore, the
  23. iterator can point into the sequence (returning a value when dereferenced
  24. and being incrementable), or be off-the-end (and not dereferenceable or
  25. incrementable).</para>
  26. </description>
  27. <associated-type name="value_type">
  28. <get-member-type name="value_type">
  29. <apply-template name="std::iterator_traits">
  30. <type name="Iter"/>
  31. </apply-template>
  32. </get-member-type>
  33. <description><simpara>The value type of the iterator</simpara></description>
  34. </associated-type>
  35. <refines const="no" concept="ForwardIterator"/>
  36. <notation variables="i j">
  37. <sample-value>
  38. <type name="Iter"/>
  39. </sample-value>
  40. </notation>
  41. <associated-type name="category">
  42. <get-member-type name="iterator_category">
  43. <apply-template name="std::iterator_traits">
  44. <type name="Iter"/>
  45. </apply-template>
  46. </get-member-type>
  47. <description><simpara>The category of the iterator</simpara></description>
  48. </associated-type>
  49. <notation variables="x">
  50. <sample-value>
  51. <type name="value_type"/>
  52. </sample-value>
  53. </notation>
  54. <valid-type-expression name="Category tag">
  55. <description/>
  56. <type name="category"/>
  57. <return-type>
  58. <derived-from testable="yes">
  59. <type name="std::bidirectional_iterator_tag"/>
  60. </derived-from>
  61. </return-type>
  62. </valid-type-expression>
  63. <valid-expression name="Predecrement">
  64. <predecrement>
  65. <sample-value><reference-to><type name="Iter"/></reference-to></sample-value>
  66. </predecrement>
  67. <return-type>
  68. <require-same-type testable="yes">
  69. <reference-to><type name="Iter"/></reference-to>
  70. </require-same-type>
  71. </return-type>
  72. <precondition><code>i</code> is incrementable (not
  73. off-the-end) and some dereferenceable iterator <code>j</code> exists
  74. such that <code>i == ++j</code></precondition>
  75. </valid-expression>
  76. <valid-expression name="Postdecrement">
  77. <postdecrement>
  78. <sample-value><reference-to><type name="Iter"/></reference-to></sample-value>
  79. </postdecrement>
  80. <return-type>
  81. <require-same-type testable="yes"><type name="Iter"/></require-same-type>
  82. </return-type>
  83. <precondition>Same as for predecrement</precondition>
  84. <semantics>Equivalent to <code>{Iter j = i; --i; return j;}</code></semantics>
  85. <postcondition><code>i</code> is dereferenceable or
  86. off-the-end</postcondition>
  87. </valid-expression>
  88. <complexity>
  89. All iterator operations must take amortized constant time.
  90. </complexity>
  91. <invariant name="Predecrement must return object">
  92. <code>&amp;i = &amp;(--i)</code>
  93. </invariant>
  94. <invariant name="Unique path through sequence">
  95. <code>i == j</code> implies <code>--i == --j</code>
  96. </invariant>
  97. <invariant name="Increment and decrement are inverses">
  98. <code>++i; --i;</code> and <code>--i; ++i;</code> must end up with the
  99. value of <code>i</code> unmodified, if <code>i</code> both of the
  100. operations in the pair are valid.
  101. </invariant>
  102. <example-model>
  103. <pointer-to>
  104. <type name="T"/>
  105. </pointer-to>
  106. </example-model>
  107. <example-model>
  108. <get-member-type name="iterator">
  109. <apply-template name="std::list">
  110. <type name="T"/>
  111. </apply-template>
  112. </get-member-type>
  113. </example-model>
  114. <see-also concept="RandomAccessIterator"/>
  115. </concept>