index.html 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Chapter&#160;1.&#160;Boost.Icl</title>
  5. <link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
  7. <link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.Icl">
  8. <link rel="next" href="boost_icl/examples.html" title="Examples">
  9. </head>
  10. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  11. <table cellpadding="2" width="100%"><tr>
  12. <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
  13. <td align="center"><a href="../../../../index.html">Home</a></td>
  14. <td align="center"><a href="../../../libraries.htm">Libraries</a></td>
  15. <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
  16. <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
  17. <td align="center"><a href="../../../../more/index.htm">More</a></td>
  18. </tr></table>
  19. <hr>
  20. <div class="spirit-nav"><a accesskey="n" href="boost_icl/examples.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
  21. <div class="chapter">
  22. <div class="titlepage"><div>
  23. <div><h2 class="title">
  24. <a name="optional"></a>Chapter&#160;1.&#160;Boost.Icl</h2></div>
  25. <div><div class="author"><h3 class="author">
  26. <span class="firstname">Joachim</span> <span class="surname">Faulhaber</span>
  27. </h3></div></div>
  28. <div><p class="copyright">Copyright &#169; 2007-2010 Joachim
  29. Faulhaber</p></div>
  30. <div><p class="copyright">Copyright &#169; 1999-2006 Cortex Software
  31. GmbH</p></div>
  32. <div><div class="legalnotice">
  33. <a name="optional.legal"></a><p>
  34. Distributed under the Boost Software License, Version 1.0. (See accompanying
  35. file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
  36. </p>
  37. </div></div>
  38. </div></div>
  39. <div class="toc">
  40. <p><b>Table of Contents</b></p>
  41. <dl class="toc">
  42. <dt><span class="section"><a href="index.html#boost_icl.introduction">Introduction</a></span></dt>
  43. <dd><dl>
  44. <dt><span class="section"><a href="index.html#boost_icl.introduction.definition_and_basic_example">Definition
  45. and Basic Example</a></span></dt>
  46. <dt><span class="section"><a href="index.html#boost_icl.introduction.icl_s_class_templates">Icl's class
  47. templates</a></span></dt>
  48. <dt><span class="section"><a href="index.html#boost_icl.introduction.interval_combining_styles">Interval
  49. Combining Styles</a></span></dt>
  50. </dl></dd>
  51. <dt><span class="section"><a href="boost_icl/examples.html">Examples</a></span></dt>
  52. <dd><dl>
  53. <dt><span class="section"><a href="boost_icl/examples.html#boost_icl.examples.overview">Overview</a></span></dt>
  54. <dt><span class="section"><a href="boost_icl/examples/party.html">Party</a></span></dt>
  55. <dt><span class="section"><a href="boost_icl/examples/interval.html">Interval</a></span></dt>
  56. <dt><span class="section"><a href="boost_icl/examples/dynamic_interval.html">Dynamic interval</a></span></dt>
  57. <dt><span class="section"><a href="boost_icl/examples/static_interval.html">Static interval</a></span></dt>
  58. <dt><span class="section"><a href="boost_icl/examples/interval_container.html">Interval container</a></span></dt>
  59. <dt><span class="section"><a href="boost_icl/examples/overlap_counter.html">Overlap counter</a></span></dt>
  60. <dt><span class="section"><a href="boost_icl/examples/partys_height_average.html">Party's height
  61. average</a></span></dt>
  62. <dt><span class="section"><a href="boost_icl/examples/partys_tallest_guests.html">Party's tallest
  63. guests</a></span></dt>
  64. <dt><span class="section"><a href="boost_icl/examples/time_grids.html">Time grids for months
  65. and weeks</a></span></dt>
  66. <dt><span class="section"><a href="boost_icl/examples/man_power.html">Man power</a></span></dt>
  67. <dt><span class="section"><a href="boost_icl/examples/user_groups.html">User groups</a></span></dt>
  68. <dt><span class="section"><a href="boost_icl/examples/std_copy.html">Std copy</a></span></dt>
  69. <dt><span class="section"><a href="boost_icl/examples/std_transform.html">Std transform</a></span></dt>
  70. <dt><span class="section"><a href="boost_icl/examples/custom_interval.html">Custom interval</a></span></dt>
  71. </dl></dd>
  72. <dt><span class="section"><a href="boost_icl/projects.html">Projects</a></span></dt>
  73. <dd><dl><dt><span class="section"><a href="boost_icl/projects.html#boost_icl.projects.large_bitset">Large Bitset</a></span></dt></dl></dd>
  74. <dt><span class="section"><a href="boost_icl/concepts.html">Concepts</a></span></dt>
  75. <dd><dl>
  76. <dt><span class="section"><a href="boost_icl/concepts.html#boost_icl.concepts.naming">Naming</a></span></dt>
  77. <dt><span class="section"><a href="boost_icl/concepts/aspects.html">Aspects</a></span></dt>
  78. <dt><span class="section"><a href="boost_icl/concepts/sets_and_maps.html">Sets and Maps</a></span></dt>
  79. <dt><span class="section"><a href="boost_icl/concepts/aggrovering.html">Addability, Subtractability
  80. and Aggregate on Overlap</a></span></dt>
  81. <dt><span class="section"><a href="boost_icl/concepts/map_traits.html">Map Traits</a></span></dt>
  82. </dl></dd>
  83. <dt><span class="section"><a href="boost_icl/semantics.html">Semantics</a></span></dt>
  84. <dd><dl>
  85. <dt><span class="section"><a href="boost_icl/semantics.html#boost_icl.semantics.orderings_and_equivalences">Orderings
  86. and Equivalences</a></span></dt>
  87. <dt><span class="section"><a href="boost_icl/semantics/sets.html">Sets</a></span></dt>
  88. <dt><span class="section"><a href="boost_icl/semantics/maps.html">Maps</a></span></dt>
  89. <dt><span class="section"><a href="boost_icl/semantics/collectors__maps_of_sets.html">Collectors:
  90. Maps of Sets</a></span></dt>
  91. <dt><span class="section"><a href="boost_icl/semantics/quantifiers__maps_of_numbers.html">Quantifiers:
  92. Maps of Numbers</a></span></dt>
  93. <dt><span class="section"><a href="boost_icl/semantics/concept_induction.html">Concept Induction</a></span></dt>
  94. </dl></dd>
  95. <dt><span class="section"><a href="boost_icl/interface.html">Interface</a></span></dt>
  96. <dd><dl>
  97. <dt><span class="section"><a href="boost_icl/interface.html#boost_icl.interface.class_templates">Class templates</a></span></dt>
  98. <dt><span class="section"><a href="boost_icl/interface/required_concepts.html">Required Concepts</a></span></dt>
  99. <dt><span class="section"><a href="boost_icl/interface/associated_types.html">Associated Types</a></span></dt>
  100. <dt><span class="section"><a href="boost_icl/interface/function_synopsis.html">Function Synopsis</a></span></dt>
  101. </dl></dd>
  102. <dt><span class="section"><a href="boost_icl/customization.html">Customization</a></span></dt>
  103. <dd><dl><dt><span class="section"><a href="boost_icl/customization.html#boost_icl.customization.intervals">Intervals</a></span></dt></dl></dd>
  104. <dt><span class="section"><a href="boost_icl/implementation.html">Implementation</a></span></dt>
  105. <dd><dl>
  106. <dt><span class="section"><a href="boost_icl/implementation.html#boost_icl.implementation.iterative_size">Iterative size</a></span></dt>
  107. <dt><span class="section"><a href="boost_icl/implementation/complexity.html">Complexity</a></span></dt>
  108. <dt><span class="section"><a href="boost_icl/implementation/inplace_and_infix_operators.html">Inplace
  109. and infix operators</a></span></dt>
  110. </dl></dd>
  111. <dt><span class="section"><a href="boost_icl/function_reference.html">Function Reference</a></span></dt>
  112. <dd><dl>
  113. <dt><span class="section"><a href="boost_icl/function_reference.html#boost_icl.function_reference.overload_tables">Overload
  114. tables</a></span></dt>
  115. <dt><span class="section"><a href="boost_icl/function_reference/segmentational_fineness.html">Segmentational
  116. Fineness</a></span></dt>
  117. <dt><span class="section"><a href="boost_icl/function_reference/key_types.html">Key Types</a></span></dt>
  118. <dt><span class="section"><a href="boost_icl/function_reference/construct__copy__destruct.html">Construct,
  119. copy, destruct</a></span></dt>
  120. <dt><span class="section"><a href="boost_icl/function_reference/containedness.html">Containedness</a></span></dt>
  121. <dt><span class="section"><a href="boost_icl/function_reference/equivalences_and_orderings.html">Equivalences
  122. and Orderings</a></span></dt>
  123. <dt><span class="section"><a href="boost_icl/function_reference/size.html">Size</a></span></dt>
  124. <dt><span class="section"><a href="boost_icl/function_reference/range.html">Range</a></span></dt>
  125. <dt><span class="section"><a href="boost_icl/function_reference/selection.html">Selection</a></span></dt>
  126. <dt><span class="section"><a href="boost_icl/function_reference/addition.html">Addition</a></span></dt>
  127. <dt><span class="section"><a href="boost_icl/function_reference/subtraction.html">Subtraction</a></span></dt>
  128. <dt><span class="section"><a href="boost_icl/function_reference/insertion.html">Insertion</a></span></dt>
  129. <dt><span class="section"><a href="boost_icl/function_reference/erasure.html">Erasure</a></span></dt>
  130. <dt><span class="section"><a href="boost_icl/function_reference/intersection.html">Intersection</a></span></dt>
  131. <dt><span class="section"><a href="boost_icl/function_reference/symmetric_difference.html">Symmetric
  132. Difference</a></span></dt>
  133. <dt><span class="section"><a href="boost_icl/function_reference/iterator_related.html">Iterator
  134. related</a></span></dt>
  135. <dt><span class="section"><a href="boost_icl/function_reference/element_iteration.html">Element
  136. iteration</a></span></dt>
  137. <dt><span class="section"><a href="boost_icl/function_reference/streaming__conversion.html">Streaming,
  138. conversion</a></span></dt>
  139. <dt><span class="section"><a href="boost_icl/function_reference/interval_construction.html">Interval
  140. Construction</a></span></dt>
  141. <dt><span class="section"><a href="boost_icl/function_reference/additional_interval_orderings.html">Additional
  142. Interval Orderings</a></span></dt>
  143. <dt><span class="section"><a href="boost_icl/function_reference/miscellaneous_interval_functions.html">Miscellaneous
  144. Interval Functions</a></span></dt>
  145. </dl></dd>
  146. <dt><span class="section"><a href="boost_icl/acknowledgments.html">Acknowledgments</a></span></dt>
  147. <dt><span class="section"><a href="interval_container_library_reference.html">Interval Container Library Reference</a></span></dt>
  148. <dd><dl>
  149. <dt><span class="section"><a href="interval_container_library_reference.html#header.boost.icl.closed_interval_hpp">Header &lt;boost/icl/closed_interval.hpp&gt;</a></span></dt>
  150. <dt><span class="section"><a href="header/boost/icl/continuous_interval_hpp.html">Header &lt;boost/icl/continuous_interval.hpp&gt;</a></span></dt>
  151. <dt><span class="section"><a href="header/boost/icl/discrete_interval_hpp.html">Header &lt;boost/icl/discrete_interval.hpp&gt;</a></span></dt>
  152. <dt><span class="section"><a href="header/boost/icl/dynamic_interval_traits_hpp.html">Header &lt;boost/icl/dynamic_interval_traits.hpp&gt;</a></span></dt>
  153. <dt><span class="section"><a href="header/boost/icl/functors_hpp.html">Header &lt;boost/icl/functors.hpp&gt;</a></span></dt>
  154. <dt><span class="section"><a href="header/boost/icl/gregorian_hpp.html">Header &lt;boost/icl/gregorian.hpp&gt;</a></span></dt>
  155. <dt><span class="section"><a href="header/boost/icl/impl_config_hpp.html">Header &lt;boost/icl/impl_config.hpp&gt;</a></span></dt>
  156. <dt><span class="section"><a href="header/boost/icl/interval_hpp.html">Header &lt;boost/icl/interval.hpp&gt;</a></span></dt>
  157. <dt><span class="section"><a href="header/boost/icl/interval_base_map_hpp.html">Header &lt;boost/icl/interval_base_map.hpp&gt;</a></span></dt>
  158. <dt><span class="section"><a href="header/boost/icl/interval_base_set_hpp.html">Header &lt;boost/icl/interval_base_set.hpp&gt;</a></span></dt>
  159. <dt><span class="section"><a href="header/boost/icl/interval_bounds_hpp.html">Header &lt;boost/icl/interval_bounds.hpp&gt;</a></span></dt>
  160. <dt><span class="section"><a href="header/boost/icl/interval_combining_style_hpp.html">Header &lt;boost/icl/interval_combining_style.hpp&gt;</a></span></dt>
  161. <dt><span class="section"><a href="header/boost/icl/interval_map_hpp.html">Header &lt;boost/icl/interval_map.hpp&gt;</a></span></dt>
  162. <dt><span class="section"><a href="header/boost/icl/interval_set_hpp.html">Header &lt;boost/icl/interval_set.hpp&gt;</a></span></dt>
  163. <dt><span class="section"><a href="header/boost/icl/interval_traits_hpp.html">Header &lt;boost/icl/interval_traits.hpp&gt;</a></span></dt>
  164. <dt><span class="section"><a href="header/boost/icl/iterator_hpp.html">Header &lt;boost/icl/iterator.hpp&gt;</a></span></dt>
  165. <dt><span class="section"><a href="header/boost/icl/left_open_interval_hpp.html">Header &lt;boost/icl/left_open_interval.hpp&gt;</a></span></dt>
  166. <dt><span class="section"><a href="header/boost/icl/map_hpp.html">Header &lt;boost/icl/map.hpp&gt;</a></span></dt>
  167. <dt><span class="section"><a href="header/boost/icl/open_interval_hpp.html">Header &lt;boost/icl/open_interval.hpp&gt;</a></span></dt>
  168. <dt><span class="section"><a href="header/boost/icl/ptime_hpp.html">Header &lt;boost/icl/ptime.hpp&gt;</a></span></dt>
  169. <dt><span class="section"><a href="header/boost/icl/rational_hpp.html">Header &lt;boost/icl/rational.hpp&gt;</a></span></dt>
  170. <dt><span class="section"><a href="header/boost/icl/right_open_interval_hpp.html">Header &lt;boost/icl/right_open_interval.hpp&gt;</a></span></dt>
  171. <dt><span class="section"><a href="header/boost/icl/separate_interval_set_hpp.html">Header &lt;boost/icl/separate_interval_set.hpp&gt;</a></span></dt>
  172. <dt><span class="section"><a href="header/boost/icl/split_interval_map_hpp.html">Header &lt;boost/icl/split_interval_map.hpp&gt;</a></span></dt>
  173. <dt><span class="section"><a href="header/boost/icl/split_interval_set_hpp.html">Header &lt;boost/icl/split_interval_set.hpp&gt;</a></span></dt>
  174. </dl></dd>
  175. </dl>
  176. </div>
  177. <div class="section">
  178. <div class="titlepage"><div><div><h2 class="title" style="clear: both">
  179. <a name="boost_icl.introduction"></a><a class="link" href="index.html#boost_icl.introduction" title="Introduction">Introduction</a>
  180. </h2></div></div></div>
  181. <div class="toc"><dl class="toc">
  182. <dt><span class="section"><a href="index.html#boost_icl.introduction.definition_and_basic_example">Definition
  183. and Basic Example</a></span></dt>
  184. <dt><span class="section"><a href="index.html#boost_icl.introduction.icl_s_class_templates">Icl's class
  185. templates</a></span></dt>
  186. <dt><span class="section"><a href="index.html#boost_icl.introduction.interval_combining_styles">Interval
  187. Combining Styles</a></span></dt>
  188. </dl></div>
  189. <p>
  190. <span class="quote">&#8220;<span class="quote">A bug crawls across the boost docs on my laptop screen. Let him be!
  191. We need all the readers we can get.</span>&#8221;</span> -- Freely adapted from <a href="http://en.wikipedia.org/wiki/Jack_Kornfield" target="_top">Jack
  192. Kornfield</a>
  193. </p>
  194. <p>
  195. Intervals are almost ubiquitous in software development. Yet they are very
  196. easily coded into user defined classes by a pair of numbers so they are only
  197. <span class="emphasis"><em>implicitly</em></span> used most of the time. The meaning of an interval
  198. is simple. They represent all the elements between their lower and upper bound
  199. and thus a set. But unlike sets, intervals usually can not be added to a single
  200. new interval. If you want to add intervals to a collection of intervals that
  201. does still represent a <span class="emphasis"><em>set</em></span>, you arrive at the idea of
  202. <span class="emphasis"><em>interval_sets</em></span> provided by this library.
  203. </p>
  204. <p>
  205. Interval containers of the <span class="bold"><strong>ICL</strong></span> have been developed
  206. initially at <a href="http://www.cortex-software.de/desktopdefault.aspx" target="_top">Cortex
  207. Software GmbH</a> to solve problems related to date and time interval computations
  208. in the context of a Hospital Information System. Time intervals with associated
  209. values like <span class="emphasis"><em>amount of invoice</em></span> or <span class="emphasis"><em>set of therapies</em></span>
  210. had to be manipulated in statistics, billing programs and therapy scheduling
  211. programs. So the <span class="bold"><strong>ICL</strong></span> emerged out of those
  212. industrial use cases. It extracts generic code that helps to solve common problems
  213. from the date and time problem domain and can be beneficial in other fields
  214. as well.
  215. </p>
  216. <p>
  217. One of the most advantageous aspects of interval containers is their very compact
  218. representation of sets and maps. Working with sets and maps <span class="emphasis"><em>of elements</em></span>
  219. can be very inefficient, if in a given problem domain, elements are typically
  220. occurring in contiguous chunks. Besides a compact representation of associative
  221. containers, that can reduce the cost of space and time drastically, the ICL
  222. comes with a universal mechanism of aggregation, that allows to combine associated
  223. values in meaningful ways when intervals overlap on insertion.
  224. </p>
  225. <p>
  226. For a condensed introduction and overview you may want to look at the <a href="http://www.herold-faulhaber.de/boost_icl/doc/libs/icl/doc/boostcon09/intro_to_itl.pdf" target="_top">presentation
  227. material on the <span class="bold"><strong>ICL</strong></span> from <span class="emphasis"><em><span class="bold"><strong>BoostCon2009</strong></span></em></span></a>.
  228. </p>
  229. <div class="section">
  230. <div class="titlepage"><div><div><h3 class="title">
  231. <a name="boost_icl.introduction.definition_and_basic_example"></a><a class="link" href="index.html#boost_icl.introduction.definition_and_basic_example" title="Definition and Basic Example">Definition
  232. and Basic Example</a>
  233. </h3></div></div></div>
  234. <p>
  235. The <span class="bold"><strong>Interval Container Library (ICL)</strong></span> provides
  236. <code class="computeroutput"><a class="link" href="boost/icl/interval.html" title="Struct template interval">intervals</a></code> and two kinds
  237. of interval containers: <code class="computeroutput"><a class="link" href="boost/icl/interval_set.html" title="Class template interval_set">interval_sets</a></code>
  238. and <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_maps</a></code>.
  239. </p>
  240. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
  241. <li class="listitem">
  242. An <code class="computeroutput"><a class="link" href="boost/icl/interval_base_set.html" title="Class template interval_base_set">interval_set</a></code>
  243. is a <span class="bold"><strong>set</strong></span> that is implemented as a set
  244. of intervals.
  245. </li>
  246. <li class="listitem">
  247. An <code class="computeroutput"><a class="link" href="boost/icl/interval_base_map.html" title="Class template interval_base_map">interval_map</a></code>
  248. is a <span class="bold"><strong>map</strong></span> that is implemented as a map
  249. of interval value pairs.
  250. </li>
  251. </ul></div>
  252. <h5>
  253. <a name="boost_icl.introduction.definition_and_basic_example.h0"></a>
  254. <span class="phrase"><a name="boost_icl.introduction.definition_and_basic_example.two_aspects"></a></span><a class="link" href="index.html#boost_icl.introduction.definition_and_basic_example.two_aspects">Two
  255. Aspects</a>
  256. </h5>
  257. <p>
  258. <code class="computeroutput"><a class="link" href="boost/icl/interval_base_set.html" title="Class template interval_base_set">Interval_sets</a></code>
  259. and <code class="computeroutput"><a class="link" href="boost/icl/interval_base_map.html" title="Class template interval_base_map">interval_maps</a></code>
  260. expose two different aspects in their interfaces: (1) The functionality of
  261. a set or a map, which is the more <span class="emphasis"><em><span class="bold"><strong>abstract
  262. aspect</strong></span></em></span>. And (2) the functionality of a container of
  263. intervals which is the more specific and <span class="emphasis"><em><span class="bold"><strong>implementation
  264. related aspect</strong></span></em></span>. In practice both aspects are useful
  265. and are therefore supported.
  266. </p>
  267. <p>
  268. The first aspect, that will be called <span class="emphasis"><em><span class="bold"><strong>fundamental</strong></span></em></span>
  269. <span class="emphasis"><em><span class="bold"><strong>aspect</strong></span></em></span>, is the more
  270. important one. It means that we can use an <code class="computeroutput"><a class="link" href="boost/icl/interval_set.html" title="Class template interval_set">interval_set</a></code>
  271. or <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code> like
  272. a set or map <span class="emphasis"><em><span class="bold"><strong>of elements</strong></span></em></span>.
  273. It exposes the same functions.
  274. </p>
  275. <pre class="programlisting"><span class="identifier">interval_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">mySet</span><span class="special">;</span>
  276. <span class="identifier">mySet</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="number">42</span><span class="special">);</span>
  277. <span class="keyword">bool</span> <span class="identifier">has_answer</span> <span class="special">=</span> <span class="identifier">contains</span><span class="special">(</span><span class="identifier">mySet</span><span class="special">,</span> <span class="number">42</span><span class="special">);</span>
  278. </pre>
  279. <p>
  280. </p>
  281. <p>
  282. The second aspect, that will be called <span class="emphasis"><em><span class="bold"><strong>segmental</strong></span></em></span>
  283. <span class="emphasis"><em><span class="bold"><strong>aspect</strong></span></em></span>, allows to exploit
  284. the fact, that the elements of <code class="computeroutput"><a class="link" href="boost/icl/interval_set.html" title="Class template interval_set">interval_sets</a></code>
  285. and <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_maps</a></code> are
  286. clustered in <span class="emphasis"><em><span class="bold"><strong>intervals</strong></span></em></span>
  287. or <span class="emphasis"><em><span class="bold"><strong>segments</strong></span></em></span> that we
  288. can iterate over.
  289. </p>
  290. <p>
  291. </p>
  292. <pre class="programlisting"><span class="comment">// Switch on my favorite telecasts using an interval_set</span>
  293. <span class="identifier">interval</span><span class="special">&lt;</span><span class="identifier">seconds</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">news</span><span class="special">(</span><span class="identifier">make_seconds</span><span class="special">(</span><span class="string">"20:00:00"</span><span class="special">),</span> <span class="identifier">make_seconds</span><span class="special">(</span><span class="string">"20:15:00"</span><span class="special">));</span>
  294. <span class="identifier">interval</span><span class="special">&lt;</span><span class="identifier">seconds</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">talk_show</span><span class="special">(</span><span class="identifier">make_seconds</span><span class="special">(</span><span class="string">"22:45:30"</span><span class="special">),</span> <span class="identifier">make_seconds</span><span class="special">(</span><span class="string">"23:30:50"</span><span class="special">));</span>
  295. <span class="identifier">interval_set</span><span class="special">&lt;</span><span class="identifier">seconds</span><span class="special">&gt;</span> <span class="identifier">myTvProgram</span><span class="special">;</span>
  296. <span class="identifier">myTvProgram</span><span class="special">.</span><span class="identifier">add</span><span class="special">(</span><span class="identifier">news</span><span class="special">).</span><span class="identifier">add</span><span class="special">(</span><span class="identifier">talk_show</span><span class="special">);</span>
  297. <span class="comment">// Iterating over elements (seconds) would be silly ...</span>
  298. <span class="keyword">for</span><span class="special">(</span><span class="identifier">interval_set</span><span class="special">&lt;</span><span class="identifier">seconds</span><span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">telecast</span> <span class="special">=</span> <span class="identifier">myTvProgram</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span>
  299. <span class="identifier">telecast</span> <span class="special">!=</span> <span class="identifier">myTvProgram</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">telecast</span><span class="special">)</span>
  300. <span class="comment">//...so this iterates over intervals</span>
  301. <span class="identifier">TV</span><span class="special">.</span><span class="identifier">switch_on</span><span class="special">(*</span><span class="identifier">telecast</span><span class="special">);</span>
  302. </pre>
  303. <p>
  304. </p>
  305. <p>
  306. Working with <code class="computeroutput"><a class="link" href="boost/icl/interval_base_set.html" title="Class template interval_base_set">interval_sets</a></code>
  307. and <code class="computeroutput"><a class="link" href="boost/icl/interval_base_map.html" title="Class template interval_base_map">interval_maps</a></code>
  308. can be beneficial whenever the elements of sets appear in contiguous chunks:
  309. <code class="computeroutput"><a class="link" href="boost/icl/interval.html" title="Struct template interval">intervals</a></code>. This is obviously
  310. the case in many problem domains, particularly in fields that deal with computations
  311. related to date and time.
  312. </p>
  313. <h5>
  314. <a name="boost_icl.introduction.definition_and_basic_example.h1"></a>
  315. <span class="phrase"><a name="boost_icl.introduction.definition_and_basic_example.addabitlity_and_subtractability"></a></span><a class="link" href="index.html#boost_icl.introduction.definition_and_basic_example.addabitlity_and_subtractability">Addabitlity
  316. and Subtractability</a>
  317. </h5>
  318. <p>
  319. Unlike <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">sets</span></code> and <code class="computeroutput"><span class="identifier">maps</span></code>,
  320. <code class="computeroutput"><a class="link" href="boost/icl/interval_base_set.html" title="Class template interval_base_set">interval_sets</a></code>
  321. and <code class="computeroutput"><a class="link" href="boost/icl/interval_base_map.html" title="Class template interval_base_map">interval_maps</a></code>
  322. implement concept <code class="computeroutput"><span class="identifier">Addable</span></code>
  323. and <code class="computeroutput"><span class="identifier">Subtractable</span></code>. So <code class="computeroutput"><a class="link" href="boost/icl/interval_base_set.html" title="Class template interval_base_set">interval_sets</a></code> define an
  324. <code class="computeroutput"><span class="keyword">operator</span> <span class="special">+=</span></code>
  325. that is naturally implemented as <span class="emphasis"><em><span class="bold"><strong>set union</strong></span></em></span>
  326. and an <code class="computeroutput"><span class="keyword">operator</span> <span class="special">-=</span></code>
  327. that is consequently implemented as <span class="emphasis"><em><span class="bold"><strong>set difference</strong></span></em></span>.
  328. In the <span class="bold"><strong>Icl</strong></span> <code class="computeroutput"><a class="link" href="boost/icl/interval_base_map.html" title="Class template interval_base_map">interval_maps</a></code>
  329. are addable and subtractable as well. It turned out to be a very fruitful
  330. concept to propagate the addition or subtraction to the <code class="computeroutput"><a class="link" href="boost/icl/interval_base_map.html" title="Class template interval_base_map">interval_map's</a></code>
  331. associated values in cases where the insertion of an interval value pair
  332. into an <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code>
  333. resulted in a collision of the inserted interval value pair with interval
  334. value pairs, that are already in the <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code>.
  335. This operation propagation is called <span class="emphasis"><em><span class="bold"><strong>aggregate
  336. on overlap</strong></span></em></span>.
  337. </p>
  338. <h5>
  339. <a name="boost_icl.introduction.definition_and_basic_example.h2"></a>
  340. <span class="phrase"><a name="boost_icl.introduction.definition_and_basic_example.aggregate_on_overlap"></a></span><a class="link" href="index.html#boost_icl.introduction.definition_and_basic_example.aggregate_on_overlap">Aggregate
  341. on Overlap</a>
  342. </h5>
  343. <p>
  344. This is a first motivating example of a very small party, demonstrating the
  345. <span class="emphasis"><em><span class="bold"><strong>aggregate on overlap</strong></span></em></span>
  346. principle on <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_maps</a></code>:
  347. </p>
  348. <p>
  349. In the example Mary enters the party first. She attends during the time interval
  350. <code class="computeroutput"><span class="special">[</span><span class="number">20</span><span class="special">:</span><span class="number">00</span><span class="special">,</span><span class="number">22</span><span class="special">:</span><span class="number">00</span><span class="special">)</span></code>. Harry enters later. He stays within <code class="computeroutput"><span class="special">[</span><span class="number">21</span><span class="special">:</span><span class="number">00</span><span class="special">,</span><span class="number">23</span><span class="special">:</span><span class="number">00</span><span class="special">)</span></code>.
  351. </p>
  352. <pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span> <span class="identifier">guests</span><span class="special">;</span>
  353. <span class="identifier">interval_map</span><span class="special">&lt;</span><span class="identifier">time</span><span class="special">,</span> <span class="identifier">guests</span><span class="special">&gt;</span> <span class="identifier">party</span><span class="special">;</span>
  354. <span class="identifier">party</span> <span class="special">+=</span> <span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">interval</span><span class="special">&lt;</span><span class="identifier">time</span><span class="special">&gt;::</span><span class="identifier">right_open</span><span class="special">(</span><span class="identifier">time</span><span class="special">(</span><span class="string">"20:00"</span><span class="special">),</span> <span class="identifier">time</span><span class="special">(</span><span class="string">"22:00"</span><span class="special">)),</span> <span class="identifier">guests</span><span class="special">(</span><span class="string">"Mary"</span><span class="special">));</span>
  355. <span class="identifier">party</span> <span class="special">+=</span> <span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">interval</span><span class="special">&lt;</span><span class="identifier">time</span><span class="special">&gt;::</span><span class="identifier">right_open</span><span class="special">(</span><span class="identifier">time</span><span class="special">(</span><span class="string">"21:00"</span><span class="special">),</span> <span class="identifier">time</span><span class="special">(</span><span class="string">"23:00"</span><span class="special">)),</span> <span class="identifier">guests</span><span class="special">(</span><span class="string">"Harry"</span><span class="special">));</span>
  356. <span class="comment">// party now contains</span>
  357. <span class="special">[</span><span class="number">20</span><span class="special">:</span><span class="number">00</span><span class="special">,</span> <span class="number">21</span><span class="special">:</span><span class="number">00</span><span class="special">)-&gt;{</span><span class="string">"Mary"</span><span class="special">}</span>
  358. <span class="special">[</span><span class="number">21</span><span class="special">:</span><span class="number">00</span><span class="special">,</span> <span class="number">22</span><span class="special">:</span><span class="number">00</span><span class="special">)-&gt;{</span><span class="string">"Harry"</span><span class="special">,</span><span class="string">"Mary"</span><span class="special">}</span> <span class="comment">//guest sets aggregated on overlap</span>
  359. <span class="special">[</span><span class="number">22</span><span class="special">:</span><span class="number">00</span><span class="special">,</span> <span class="number">23</span><span class="special">:</span><span class="number">00</span><span class="special">)-&gt;{</span><span class="string">"Harry"</span><span class="special">}</span>
  360. </pre>
  361. <p>
  362. <span class="emphasis"><em><span class="bold"><strong>On overlap of intervals</strong></span></em></span>,
  363. the corresponding name sets are <span class="emphasis"><em><span class="bold"><strong>accumulated</strong></span></em></span>.
  364. At the <span class="emphasis"><em><span class="bold"><strong>points of overlap</strong></span></em></span>
  365. the intervals are <span class="emphasis"><em><span class="bold"><strong>split</strong></span></em></span>.
  366. The accumulation of content on overlap of intervals is done via an <code class="computeroutput"><span class="keyword">operator</span> <span class="special">+=</span></code>
  367. that has to be implemented for the associated values of the <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code>.
  368. In the example the associated values are <code class="computeroutput"><span class="identifier">guest</span>
  369. <span class="identifier">sets</span></code>. Thus a <code class="computeroutput"><span class="identifier">guest</span>
  370. <span class="identifier">set</span></code> has to implement <code class="computeroutput"><span class="keyword">operator</span> <span class="special">+=</span></code>
  371. as set union.
  372. </p>
  373. <p>
  374. As can be seen from the example an <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code>
  375. has both a <span class="emphasis"><em><span class="bold"><strong>decompositional behavior</strong></span></em></span>
  376. (on the time dimension) as well as an <span class="emphasis"><em><span class="bold"><strong>accumulative
  377. one</strong></span></em></span> (on the associated values).
  378. </p>
  379. <p>
  380. Addability and aggregate on overlap are useful features on <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_maps</a></code>
  381. implemented via function <code class="computeroutput"><span class="identifier">add</span></code>
  382. and <code class="computeroutput"><span class="keyword">operator</span> <span class="special">+=</span></code>.
  383. But you can also use them with the <span class="emphasis"><em>traditional</em></span> <a class="link" href="boost_icl/function_reference/insertion.html" title="Insertion">insert semantics</a>
  384. that behaves like <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">::</span><span class="identifier">insert</span></code>
  385. generalized for interval insertion.
  386. </p>
  387. </div>
  388. <div class="section">
  389. <div class="titlepage"><div><div><h3 class="title">
  390. <a name="boost_icl.introduction.icl_s_class_templates"></a><a class="link" href="index.html#boost_icl.introduction.icl_s_class_templates" title="Icl's class templates">Icl's class
  391. templates</a>
  392. </h3></div></div></div>
  393. <p>
  394. In addition to interval containers we can work with containers of elements
  395. that are <span class="emphasis"><em><span class="bold"><strong>behavioral equal</strong></span></em></span>
  396. to the interval containers: On the fundamental aspect they have exactly the
  397. same functionality. An <a href="http://www.cplusplus.com/reference/stl/set/" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code>
  398. </a> of the STL is such an equivalent set implementation. Due to the
  399. aggregation facilities of the icl's interval maps <a href="http://www.cplusplus.com/reference/stl/set/" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span></code>
  400. </a> is fundamentally not completely equivalent to an <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code>.
  401. Therefore there is an extra <code class="computeroutput"><a class="link" href="boost/icl/map.html" title="Class template map">icl::map</a></code>
  402. class template for maps of elements in the icl.
  403. </p>
  404. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
  405. <li class="listitem">
  406. The <a href="http://www.cplusplus.com/reference/stl/set/" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code> </a> is behavioral equal to
  407. <code class="computeroutput"><a class="link" href="boost/icl/interval_base_set.html" title="Class template interval_base_set">interval_sets</a></code>
  408. on the <span class="emphasis"><em><span class="bold"><strong>fundamental</strong></span></em></span>
  409. aspect.
  410. </li>
  411. <li class="listitem">
  412. An <code class="computeroutput"><a class="link" href="boost/icl/map.html" title="Class template map">icl::map</a></code> is behavioral
  413. equal to <code class="computeroutput"><a class="link" href="boost/icl/interval_base_map.html" title="Class template interval_base_map">interval_maps</a></code>
  414. on the <span class="emphasis"><em><span class="bold"><strong>fundamental</strong></span></em></span>
  415. aspect. Specifically an <code class="computeroutput"><a class="link" href="boost/icl/map.html" title="Class template map">icl::map</a></code>
  416. implements <span class="emphasis"><em><span class="bold"><strong>aggregate on overlap</strong></span></em></span>,
  417. which is named <span class="emphasis"><em><span class="bold"><strong>aggregate on collision</strong></span></em></span>
  418. for an element container.
  419. </li>
  420. </ul></div>
  421. <p>
  422. The following tables give an overview over the main class templates provided
  423. by the <span class="bold"><strong>icl</strong></span>.
  424. </p>
  425. <div class="table">
  426. <a name="boost_icl.introduction.icl_s_class_templates.t0"></a><p class="title"><b>Table&#160;1.1.&#160;Interval class templates</b></p>
  427. <div class="table-contents"><table class="table" summary="Interval class templates">
  428. <colgroup>
  429. <col>
  430. <col>
  431. <col>
  432. </colgroup>
  433. <thead><tr>
  434. <th>
  435. <p>
  436. group
  437. </p>
  438. </th>
  439. <th>
  440. <p>
  441. form
  442. </p>
  443. </th>
  444. <th>
  445. <p>
  446. template
  447. </p>
  448. </th>
  449. </tr></thead>
  450. <tbody>
  451. <tr>
  452. <td>
  453. <p>
  454. statically bounded
  455. </p>
  456. </td>
  457. <td>
  458. <p>
  459. asymmetric
  460. </p>
  461. </td>
  462. <td>
  463. <p>
  464. <code class="computeroutput"><a class="link" href="boost/icl/right_open_interval.html" title="Class template right_open_interval">right_open_interval</a></code>
  465. </p>
  466. </td>
  467. </tr>
  468. <tr>
  469. <td>
  470. </td>
  471. <td>
  472. </td>
  473. <td>
  474. <p>
  475. <code class="computeroutput"><a class="link" href="boost/icl/left_open_interval.html" title="Class template left_open_interval">left_open_interval</a></code>
  476. </p>
  477. </td>
  478. </tr>
  479. <tr>
  480. <td>
  481. </td>
  482. <td>
  483. <p>
  484. symmetric
  485. </p>
  486. </td>
  487. <td>
  488. <p>
  489. <code class="computeroutput"><a class="link" href="boost/icl/closed_interval.html" title="Class template closed_interval">closed_interval</a></code>
  490. </p>
  491. </td>
  492. </tr>
  493. <tr>
  494. <td>
  495. </td>
  496. <td>
  497. </td>
  498. <td>
  499. <p>
  500. <code class="computeroutput"><a class="link" href="boost/icl/open_interval.html" title="Class template open_interval">open_interval</a></code>
  501. </p>
  502. </td>
  503. </tr>
  504. <tr>
  505. <td>
  506. <p>
  507. dynamically bounded
  508. </p>
  509. </td>
  510. <td>
  511. </td>
  512. <td>
  513. <p>
  514. <code class="computeroutput"><a class="link" href="boost/icl/discrete_interval.html" title="Class template discrete_interval">discrete_interval</a></code>
  515. </p>
  516. </td>
  517. </tr>
  518. <tr>
  519. <td>
  520. </td>
  521. <td>
  522. </td>
  523. <td>
  524. <p>
  525. <code class="computeroutput"><a class="link" href="boost/icl/continuous_interval.html" title="Class template continuous_interval">continuous_interval</a></code>
  526. </p>
  527. </td>
  528. </tr>
  529. </tbody>
  530. </table></div>
  531. </div>
  532. <br class="table-break"><p>
  533. Statically bounded intervals always have the same kind of interval borders,
  534. e.g. right open borders<code class="computeroutput"><span class="special">[</span><span class="identifier">a</span><span class="special">..</span><span class="identifier">b</span><span class="special">)</span></code>
  535. for <code class="computeroutput"><a class="link" href="boost/icl/right_open_interval.html" title="Class template right_open_interval">right_open_interval</a></code>.
  536. Dynamically bounded intervals can have different borders. Refer to the chapter
  537. about <a class="link" href="boost_icl/interface.html#boost_icl.interface.class_templates.intervals" title="Intervals"><span class="emphasis"><em><span class="bold"><strong>intervals</strong></span></em></span></a> for details.
  538. </p>
  539. <div class="table">
  540. <a name="boost_icl.introduction.icl_s_class_templates.t1"></a><p class="title"><b>Table&#160;1.2.&#160;Container class templates</b></p>
  541. <div class="table-contents"><table class="table" summary="Container class templates">
  542. <colgroup>
  543. <col>
  544. <col>
  545. <col>
  546. <col>
  547. </colgroup>
  548. <thead><tr>
  549. <th>
  550. <p>
  551. granularity
  552. </p>
  553. </th>
  554. <th>
  555. <p>
  556. style
  557. </p>
  558. </th>
  559. <th>
  560. <p>
  561. sets
  562. </p>
  563. </th>
  564. <th>
  565. <p>
  566. maps
  567. </p>
  568. </th>
  569. </tr></thead>
  570. <tbody>
  571. <tr>
  572. <td>
  573. <p>
  574. interval
  575. </p>
  576. </td>
  577. <td>
  578. <p>
  579. joining
  580. </p>
  581. </td>
  582. <td>
  583. <p>
  584. <code class="computeroutput"><a class="link" href="boost/icl/interval_set.html" title="Class template interval_set">interval_set</a></code>
  585. </p>
  586. </td>
  587. <td>
  588. <p>
  589. <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code>
  590. </p>
  591. </td>
  592. </tr>
  593. <tr>
  594. <td>
  595. </td>
  596. <td>
  597. <p>
  598. separating
  599. </p>
  600. </td>
  601. <td>
  602. <p>
  603. <code class="computeroutput"><a class="link" href="boost/icl/separate_interval_set.html" title="Class template separate_interval_set">separate_interval_set</a></code>
  604. </p>
  605. </td>
  606. <td>
  607. </td>
  608. </tr>
  609. <tr>
  610. <td>
  611. </td>
  612. <td>
  613. <p>
  614. splitting
  615. </p>
  616. </td>
  617. <td>
  618. <p>
  619. <code class="computeroutput"><a class="link" href="boost/icl/split_interval_set.html" title="Class template split_interval_set">split_interval_set</a></code>
  620. </p>
  621. </td>
  622. <td>
  623. <p>
  624. <code class="computeroutput"><a class="link" href="boost/icl/split_interval_map.html" title="Class template split_interval_map">split_interval_map</a></code>
  625. </p>
  626. </td>
  627. </tr>
  628. <tr>
  629. <td>
  630. <p>
  631. element
  632. </p>
  633. </td>
  634. <td>
  635. </td>
  636. <td>
  637. <p>
  638. (<a href="http://www.cplusplus.com/reference/stl/set/" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code> </a>)
  639. </p>
  640. </td>
  641. <td>
  642. <p>
  643. <code class="computeroutput"><a class="link" href="boost/icl/map.html" title="Class template map">map</a></code>
  644. </p>
  645. </td>
  646. </tr>
  647. </tbody>
  648. </table></div>
  649. </div>
  650. <br class="table-break"><p>
  651. <a href="http://www.cplusplus.com/reference/stl/set/" target="_top"><code class="computeroutput"><span class="identifier">Std</span><span class="special">::</span><span class="identifier">set</span></code>
  652. </a> is placed in paretheses, because it is not a class template of the
  653. <span class="bold"><strong>ICL</strong></span>. It can be used as element container
  654. though that is behavioral equal to the ICL's interval sets on their fundamental
  655. aspect. Column <span class="emphasis"><em><span class="bold"><strong>style</strong></span></em></span>
  656. refers to the different ways in which interval containers combine added intervals.
  657. These <span class="emphasis"><em><span class="bold"><strong>combining styles</strong></span></em></span>
  658. are described in the next section.
  659. </p>
  660. </div>
  661. <div class="section">
  662. <div class="titlepage"><div><div><h3 class="title">
  663. <a name="boost_icl.introduction.interval_combining_styles"></a><a class="link" href="index.html#boost_icl.introduction.interval_combining_styles" title="Interval Combining Styles">Interval
  664. Combining Styles</a>
  665. </h3></div></div></div>
  666. <p>
  667. When we add intervals or interval value pairs to interval containers, the
  668. intervals can be added in different ways: Intervals can be joined or split
  669. or kept separate. The different interval combining styles are shown by example
  670. in the tables below.
  671. </p>
  672. <div class="table">
  673. <a name="boost_icl.introduction.interval_combining_styles.t0"></a><p class="title"><b>Table&#160;1.3.&#160;Interval container's ways to combine intervals</b></p>
  674. <div class="table-contents"><table class="table" summary="Interval container's ways to combine intervals">
  675. <colgroup>
  676. <col>
  677. <col>
  678. <col>
  679. <col>
  680. </colgroup>
  681. <thead><tr>
  682. <th>
  683. </th>
  684. <th>
  685. <p>
  686. joining
  687. </p>
  688. </th>
  689. <th>
  690. <p>
  691. separating
  692. </p>
  693. </th>
  694. <th>
  695. <p>
  696. splitting
  697. </p>
  698. </th>
  699. </tr></thead>
  700. <tbody>
  701. <tr>
  702. <td>
  703. <p>
  704. set
  705. </p>
  706. </td>
  707. <td>
  708. <p>
  709. <code class="computeroutput"><a class="link" href="boost/icl/interval_set.html" title="Class template interval_set">interval_set</a></code>
  710. </p>
  711. </td>
  712. <td>
  713. <p>
  714. <code class="computeroutput"><a class="link" href="boost/icl/separate_interval_set.html" title="Class template separate_interval_set">separate_interval_set</a></code>
  715. </p>
  716. </td>
  717. <td>
  718. <p>
  719. <code class="computeroutput"><a class="link" href="boost/icl/split_interval_set.html" title="Class template split_interval_set">split_interval_set</a></code>
  720. </p>
  721. </td>
  722. </tr>
  723. <tr>
  724. <td>
  725. <p>
  726. map
  727. </p>
  728. </td>
  729. <td>
  730. <p>
  731. <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code>
  732. </p>
  733. </td>
  734. <td>
  735. </td>
  736. <td>
  737. <p>
  738. <code class="computeroutput"><a class="link" href="boost/icl/split_interval_map.html" title="Class template split_interval_map">split_interval_map</a></code>
  739. </p>
  740. </td>
  741. </tr>
  742. <tr>
  743. <td>
  744. </td>
  745. <td>
  746. <p>
  747. Intervals are joined on overlap or touch<br> (if associated values
  748. are equal).
  749. </p>
  750. </td>
  751. <td>
  752. <p>
  753. Intervals are joined on overlap, not on touch.
  754. </p>
  755. </td>
  756. <td>
  757. <p>
  758. Intervals are split on overlap.<br> All interval borders are
  759. preserved.
  760. </p>
  761. </td>
  762. </tr>
  763. </tbody>
  764. </table></div>
  765. </div>
  766. <br class="table-break"><div class="table">
  767. <a name="boost_icl.introduction.interval_combining_styles.t1"></a><p class="title"><b>Table&#160;1.4.&#160;Interval combining styles by example</b></p>
  768. <div class="table-contents"><table class="table" summary="Interval combining styles by example">
  769. <colgroup>
  770. <col>
  771. <col>
  772. <col>
  773. <col>
  774. </colgroup>
  775. <thead><tr>
  776. <th>
  777. </th>
  778. <th>
  779. <p>
  780. joining
  781. </p>
  782. </th>
  783. <th>
  784. <p>
  785. separating
  786. </p>
  787. </th>
  788. <th>
  789. <p>
  790. splitting
  791. </p>
  792. </th>
  793. </tr></thead>
  794. <tbody>
  795. <tr>
  796. <td>
  797. <p>
  798. set
  799. </p>
  800. </td>
  801. <td>
  802. <p>
  803. <code class="computeroutput"><a class="link" href="boost/icl/interval_set.html" title="Class template interval_set">interval_set</a></code>
  804. <span class="emphasis"><em>A</em></span>
  805. </p>
  806. </td>
  807. <td>
  808. <p>
  809. <code class="computeroutput"><a class="link" href="boost/icl/separate_interval_set.html" title="Class template separate_interval_set">separate_interval_set</a></code>
  810. <span class="emphasis"><em>B</em></span>
  811. </p>
  812. </td>
  813. <td>
  814. <p>
  815. <code class="computeroutput"><a class="link" href="boost/icl/split_interval_set.html" title="Class template split_interval_set">split_interval_set</a></code>
  816. <span class="emphasis"><em>C</em></span>
  817. </p>
  818. </td>
  819. </tr>
  820. <tr>
  821. <td>
  822. </td>
  823. <td>
  824. <p>
  825. </p>
  826. <pre class="programlisting"> <span class="special">{[</span><span class="number">1</span> <span class="number">3</span><span class="special">)</span> <span class="special">}</span>
  827. <span class="special">+</span> <span class="special">[</span><span class="number">2</span> <span class="number">4</span><span class="special">)</span>
  828. <span class="special">+</span> <span class="special">[</span><span class="number">4</span> <span class="number">5</span><span class="special">)</span>
  829. <span class="special">=</span> <span class="special">{[</span><span class="number">1</span> <span class="number">5</span><span class="special">)}</span></pre>
  830. <p>
  831. </p>
  832. </td>
  833. <td>
  834. <p>
  835. </p>
  836. <pre class="programlisting"> <span class="special">{[</span><span class="number">1</span> <span class="number">3</span><span class="special">)}</span> <span class="special">}</span>
  837. <span class="special">+</span> <span class="special">[</span><span class="number">2</span> <span class="number">4</span><span class="special">)</span>
  838. <span class="special">+</span> <span class="special">[</span><span class="number">4</span> <span class="number">5</span><span class="special">)</span>
  839. <span class="special">=</span> <span class="special">{[</span><span class="number">1</span> <span class="number">4</span><span class="special">)[</span><span class="number">4</span> <span class="number">5</span><span class="special">)}</span></pre>
  840. <p>
  841. </p>
  842. </td>
  843. <td>
  844. <p>
  845. </p>
  846. <pre class="programlisting"> <span class="special">{[</span><span class="number">1</span> <span class="number">3</span><span class="special">)</span> <span class="special">}</span>
  847. <span class="special">+</span> <span class="special">[</span><span class="number">2</span> <span class="number">4</span><span class="special">)</span>
  848. <span class="special">+</span> <span class="special">[</span><span class="number">4</span> <span class="number">5</span><span class="special">)</span>
  849. <span class="special">=</span> <span class="special">{[</span><span class="number">1</span> <span class="number">2</span><span class="special">)[</span><span class="number">2</span> <span class="number">3</span><span class="special">)[</span><span class="number">3</span> <span class="number">4</span><span class="special">)[</span><span class="number">4</span> <span class="number">5</span><span class="special">)}</span></pre>
  850. <p>
  851. </p>
  852. </td>
  853. </tr>
  854. <tr>
  855. <td>
  856. <p>
  857. map
  858. </p>
  859. </td>
  860. <td>
  861. <p>
  862. <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code>
  863. <span class="emphasis"><em>D</em></span>
  864. </p>
  865. </td>
  866. <td>
  867. </td>
  868. <td>
  869. <p>
  870. <code class="computeroutput"><a class="link" href="boost/icl/split_interval_map.html" title="Class template split_interval_map">split_interval_map</a></code>
  871. <span class="emphasis"><em>E</em></span>
  872. </p>
  873. </td>
  874. </tr>
  875. <tr>
  876. <td>
  877. </td>
  878. <td>
  879. <p>
  880. </p>
  881. <pre class="programlisting"> <span class="special">{[</span><span class="number">1</span> <span class="number">3</span><span class="special">)-&gt;</span><span class="number">1</span> <span class="special">}</span>
  882. <span class="special">+</span> <span class="special">[</span><span class="number">2</span> <span class="number">4</span><span class="special">)-&gt;</span><span class="number">1</span>
  883. <span class="special">+</span> <span class="special">[</span><span class="number">4</span> <span class="number">5</span><span class="special">)-&gt;</span><span class="number">1</span>
  884. <span class="special">=</span> <span class="special">{[</span><span class="number">1</span> <span class="number">2</span><span class="special">)[</span><span class="number">2</span> <span class="number">3</span><span class="special">)[</span><span class="number">3</span> <span class="number">5</span><span class="special">)</span> <span class="special">}</span>
  885. <span class="special">|</span> <span class="special">-&gt;</span><span class="number">1</span> <span class="special">-&gt;</span><span class="number">2</span> <span class="special">-&gt;</span><span class="number">1</span> <span class="special">|</span></pre>
  886. <p>
  887. </p>
  888. </td>
  889. <td>
  890. </td>
  891. <td>
  892. <p>
  893. </p>
  894. <pre class="programlisting"> <span class="special">{[</span><span class="number">1</span> <span class="number">3</span><span class="special">)-&gt;</span><span class="number">1</span> <span class="special">}</span>
  895. <span class="special">+</span> <span class="special">[</span><span class="number">2</span> <span class="number">4</span><span class="special">)-&gt;</span><span class="number">1</span>
  896. <span class="special">+</span> <span class="special">[</span><span class="number">4</span> <span class="number">5</span><span class="special">)-&gt;</span><span class="number">1</span>
  897. <span class="special">=</span> <span class="special">{[</span><span class="number">1</span> <span class="number">2</span><span class="special">)[</span><span class="number">2</span> <span class="number">3</span><span class="special">)[</span><span class="number">3</span> <span class="number">4</span><span class="special">)[</span><span class="number">4</span> <span class="number">5</span><span class="special">)</span> <span class="special">}</span>
  898. <span class="special">|</span> <span class="special">-&gt;</span><span class="number">1</span> <span class="special">-&gt;</span><span class="number">2</span> <span class="special">-&gt;</span><span class="number">1</span> <span class="special">-&gt;</span><span class="number">1</span> <span class="special">|</span></pre>
  899. <p>
  900. </p>
  901. </td>
  902. </tr>
  903. </tbody>
  904. </table></div>
  905. </div>
  906. <br class="table-break"><p>
  907. Note that <code class="literal">interval_sets</code> <span class="emphasis"><em>A</em></span>, <span class="emphasis"><em>B</em></span>
  908. and <span class="emphasis"><em>C</em></span> represent the same set of elements <code class="literal">{1,2,3,4}</code>
  909. and <code class="literal">interval_maps</code> <span class="emphasis"><em>D</em></span> and <span class="emphasis"><em>E</em></span>
  910. represent the same map of elements <code class="literal">{1-&gt;1, 2-&gt;2, 3-&gt;1, 4-&gt;1}</code>.
  911. See example program <a class="link" href="boost_icl/examples/interval_container.html" title="Interval container">Interval
  912. container</a> for an additional demo.
  913. </p>
  914. <h5>
  915. <a name="boost_icl.introduction.interval_combining_styles.h0"></a>
  916. <span class="phrase"><a name="boost_icl.introduction.interval_combining_styles.joining_interval_containers"></a></span><a class="link" href="index.html#boost_icl.introduction.interval_combining_styles.joining_interval_containers">Joining
  917. interval containers</a>
  918. </h5>
  919. <p>
  920. <code class="computeroutput"><a class="link" href="boost/icl/interval_set.html" title="Class template interval_set">Interval_set</a></code> and <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code> are always in a
  921. <span class="emphasis"><em><span class="bold"><strong>minimal representation</strong></span></em></span>.
  922. This is useful in many cases, where the points of insertion or intersection
  923. of intervals are not relevant. So in most instances <code class="computeroutput"><a class="link" href="boost/icl/interval_set.html" title="Class template interval_set">interval_set</a></code>
  924. and <code class="computeroutput"><a class="link" href="boost/icl/interval_map.html" title="Class template interval_map">interval_map</a></code> will
  925. be the first choice for an interval container.
  926. </p>
  927. <h5>
  928. <a name="boost_icl.introduction.interval_combining_styles.h1"></a>
  929. <span class="phrase"><a name="boost_icl.introduction.interval_combining_styles.splitting_interval_containers"></a></span><a class="link" href="index.html#boost_icl.introduction.interval_combining_styles.splitting_interval_containers">Splitting
  930. interval containers</a>
  931. </h5>
  932. <p>
  933. <code class="computeroutput"><a class="link" href="boost/icl/split_interval_set.html" title="Class template split_interval_set">Split_interval_set</a></code>
  934. and <code class="computeroutput"><a class="link" href="boost/icl/split_interval_map.html" title="Class template split_interval_map">split_interval_map</a></code>
  935. on the contrary have an <span class="emphasis"><em><span class="bold"><strong>insertion memory</strong></span></em></span>.
  936. They do accumulate interval borders both from additions and intersections.
  937. This is specifically useful, if we want to enrich an interval container with
  938. certain time grids, like e.g. months or calendar weeks or both. See example
  939. <a class="link" href="boost_icl/examples/time_grids.html" title="Time grids for months and weeks">time grids for months and weeks</a>.
  940. </p>
  941. <h5>
  942. <a name="boost_icl.introduction.interval_combining_styles.h2"></a>
  943. <span class="phrase"><a name="boost_icl.introduction.interval_combining_styles.separating_interval_containers"></a></span><a class="link" href="index.html#boost_icl.introduction.interval_combining_styles.separating_interval_containers">Separating
  944. interval containers</a>
  945. </h5>
  946. <p>
  947. <code class="computeroutput"><a class="link" href="boost/icl/separate_interval_set.html" title="Class template separate_interval_set">Separate_interval_set</a></code>
  948. implements the separating style. This style preserves borders, that are never
  949. passed by an overlapping interval. So if all intervals that are inserted
  950. into a <code class="computeroutput"><a class="link" href="boost/icl/separate_interval_set.html" title="Class template separate_interval_set">separate_interval_set</a></code>
  951. are generated form a certain grid that never pass say month borders, then
  952. these borders are preserved in the <code class="computeroutput"><a class="link" href="boost/icl/separate_interval_set.html" title="Class template separate_interval_set">separate_interval_set</a></code>.
  953. </p>
  954. </div>
  955. </div>
  956. <p>
  957. 14:46 15.10.2010
  958. </p>
  959. </div>
  960. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  961. <td align="left"><p><small>Last revised: December 10, 2019 at 00:22:43 GMT</small></p></td>
  962. <td align="right"><div class="copyright-footer"></div></td>
  963. </tr></table>
  964. <hr>
  965. <div class="spirit-nav"><a accesskey="n" href="boost_icl/examples.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
  966. </body>
  967. </html>