index.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>Boost.MultiIndex Documentation - Tutorial</title>
  6. <link rel="stylesheet" href="../style.css" type="text/css">
  7. <link rel="start" href="../index.html">
  8. <link rel="prev" href="../index.html">
  9. <link rel="up" href="../index.html">
  10. <link rel="next" href="basics.html">
  11. </head>
  12. <body>
  13. <h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
  14. "middle" width="277" height="86">Boost.MultiIndex Tutorial</h1>
  15. <div class="prev_link"><a href="../index.html"><img src="../prev.gif" alt="index" border="0"><br>
  16. Index
  17. </a></div>
  18. <div class="up_link"><a href="../index.html"><img src="../up.gif" alt="index" border="0"><br>
  19. Index
  20. </a></div>
  21. <div class="next_link"><a href="basics.html"><img src="../next.gif" alt="basics" border="0"><br>
  22. Basics
  23. </a></div><br clear="all" style="clear: all;">
  24. <hr>
  25. <h2>Contents</h2>
  26. <ul>
  27. <li><a href="#rationale">Rationale</a></li>
  28. <li><a href="#namespace">Namespace</a></li>
  29. <li><a href="basics.html">Basics</a></li>
  30. <li><a href="indices.html">Index types</a></li>
  31. <li><a href="key_extraction.html">Key extraction</a></li>
  32. <li><a href="creation.html">Container creation</a></li>
  33. <li><a href="debug.html">Debugging support</a></li>
  34. <li><a href="techniques.html">Techniques</a></li>
  35. </ul>
  36. <h2><a name="rationale">Rationale</a></h2>
  37. <p>
  38. STL containers are designed around the concept that each container controls its
  39. own collection of elements, giving access to them in a manner specified by the
  40. container's type: so, an <code>std::set</code> maintains the elements ordered
  41. by a specified sorting criterion, <code>std::list</code> allows for free
  42. positioning of elements along a linear sequence, and so on.
  43. </p>
  44. <p>
  45. Sometimes, the necessity arises of having different access interfaces
  46. to the same underlying collection: for instance, some data might need to be
  47. sorted according to more than one comparison predicate, or a bidirectional list
  48. might benefit from a supplemental logarithmic lookup interface. In these
  49. situations, programmers typically resort to manual compositions of different
  50. containers, a solution that generally involves a fair amount of code
  51. devoted to preserve the synchronization of the different parts of
  52. the composition. Boost.MultiIndex allows for the specification of
  53. <code>multi_index_container</code>s comprised of one or more <i>indices</i> with
  54. different interfaces to the same collection of elements. The resulting constructs
  55. are conceptually cleaner than manual compositions, and often perform much better.
  56. An important design decision has been taken that the indices of a given
  57. <code>multi_index_container</code> instantiation be specified at compile time: this
  58. gives ample room for static type checking and code optimization.
  59. </p>
  60. <p>
  61. Boost.MultiIndex takes inspiration from basic concepts of indexing arising in the
  62. theory of relational databases, though it is not intended to provide a full-fledged
  63. relational database framework. <code>multi_index_container</code> integrates seamlessly
  64. into the STL container/algorithm design, and features some extra capabilities regarding
  65. lookup operations and element updating which are useful extensions even for
  66. single-indexed containers.
  67. </p>
  68. <p align="center">
  69. <img src="multi_index_cont_example.png"
  70. alt="diagram of a multi_index_container with three indices"
  71. width="600" height="304"><br>
  72. <b>Fig. 1: Diagram of a <code>multi_index_container</code> with three indices.</b>
  73. </p>
  74. <p>
  75. The figure above depicts a <code>multi_index_container</code> composed of three indices:
  76. the first two present a set-like interface to the elements sorted by
  77. shape and id, respectively, while the latter index provides the functionality
  78. of a bidirectional list in the spirit of <code>std::list</code>. These
  79. indices act as "views" to the internal collection of elements, but they do not only
  80. provide read access to the set: insertion/deletion methods are also implemented much
  81. as those of <code>std::set</code>s or <code>std::list</code>s. Insertion of an
  82. element through one given index will only succeed if the uniqueness constraints of all
  83. indices are met.
  84. </p>
  85. <h2>
  86. <a name="namespace">Namespace</a>
  87. </h2>
  88. <p>
  89. All the public types of Boost.MultiIndex reside in namespace <code>::boost::multi_index</code>.
  90. Additionaly, the main class template <code>multi_index_container</code> and global functions
  91. <code>get</code> and <code>project</code> are lifted to namespace <code>::boost</code>
  92. by means of <code>using</code> declarations. For brevity of exposition, the fragments
  93. of code in the documentation are written as if the following declarations were in effect:
  94. </p>
  95. <blockquote><pre>
  96. <span class=keyword>using</span> <span class=keyword>namespace</span> <span class=special>::</span><span class=identifier>boost</span><span class=special>;</span>
  97. <span class=keyword>using</span> <span class=keyword>namespace</span> <span class=special>::</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>multi_index</span><span class=special>;</span>
  98. </pre></blockquote>
  99. <hr>
  100. <div class="prev_link"><a href="../index.html"><img src="../prev.gif" alt="index" border="0"><br>
  101. Index
  102. </a></div>
  103. <div class="up_link"><a href="../index.html"><img src="../up.gif" alt="index" border="0"><br>
  104. Index
  105. </a></div>
  106. <div class="next_link"><a href="basics.html"><img src="../next.gif" alt="basics" border="0"><br>
  107. Basics
  108. </a></div><br clear="all" style="clear: all;">
  109. <br>
  110. <p>Revised February 21st 2006</p>
  111. <p>&copy; Copyright 2003-2006 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
  112. Distributed under the Boost Software
  113. License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
  114. LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
  115. http://www.boost.org/LICENSE_1_0.txt</a>)
  116. </p>
  117. </body>
  118. </html>