arrays.html 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <html>
  2. <head>
  3. <meta content="text/html; charset=windows-1252" http-equiv="content-type">
  4. <title>arrays.html</title>
  5. <link rel="stylesheet" type="text/css" href="../styles.css">
  6. </head>
  7. <body>
  8. <h4>Arrays</h4>
  9. <div> An <i>array</i> is a data structure consisting of a two-element <i>tuple</i>.&nbsp;
  10. The first element is the number of elements in the <i>array</i>.&nbsp;
  11. The second element is another <i>tuple</i> of the elements in the <i>array</i>.&nbsp;
  12. For example, </div>
  13. <div class="code"> (<i>3</i>, (<i>a</i>, <i>b</i>, <i>c</i>)) </div>
  14. <div> ...is an <i>array</i> of <i>3</i> elements--<i>a</i>, <i>b</i>, and
  15. <i>c</i>. </div>
  16. <div> The primary strength of <i>arrays</i> is that they store their own
  17. size.&nbsp; Because of this, access to elements does not require the
  18. size.&nbsp; It only requires that an element exists at a certain index. </div>
  19. <div> This allows macro parameters to be variable in size and allows data
  20. states to change size without the user explicitly keeping track of the
  21. size independently.<br>
  22. <br>
  23. An <i>array </i>can be empty and have no elements. An empty array has a
  24. 0 size. The notation for an empty array is '(0,())'.<br>
  25. <br>
  26. <span style="font-style: italic;"> </span></div>
  27. <div>With variadic macro support a <i>tuple </i>has all of the
  28. functionality as an <i>array</i>, knows its own size, and is easier
  29. syntactically to use. Because of that an <i>array</i> should be used, as
  30. opposed to a <i>tuple</i>, only if your compiler does not support
  31. variadic macros. The only advantage an <i>array </i>has over a <i>tuple
  32. </i>is that an <i>array </i>can be empty while a <i>tuple </i>always
  33. has at least one element and therefore can never have a size of 0.<br>
  34. <br>
  35. Elements of an <i>array</i> can be extracted with <b>BOOST_PP_ARRAY_ELEM</b>,
  36. an <i>array's</i> size can be extracted with <b>BOOST_PP_ARRAY_SIZE</b>,
  37. and an <i>array</i> can be converted to the more primitive <i>tuple</i>
  38. data structure with <b>BOOST_PP_ARRAY_DATA</b>. </div>
  39. <h4>Primitives</h4>
  40. <ul>
  41. <li><a href="../ref/array_data.html">BOOST_PP_ARRAY_DATA</a></li>
  42. <li><a href="../ref/array_elem.html">BOOST_PP_ARRAY_ELEM</a></li>
  43. <li><a href="../ref/array_size.html">BOOST_PP_ARRAY_SIZE</a></li>
  44. </ul>
  45. <hr size="1">
  46. <div style="margin-left: 0px;"> <i>© Copyright <a href="http://www.housemarque.com"
  47. target="_top">Housemarque Oy</a> 2002</i> <br>
  48. <i>© Copyright Paul Mensonides 2002</i> </div>
  49. <div style="margin-left: 0px;">
  50. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  51. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
  52. or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  53. </div>
  54. </body>
  55. </html>