interface.qbk 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. [/
  2. Copyright (c) 2008-2010 Joachim Faulhaber
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. ]
  7. [section Interface]
  8. Section *Interface* outlines types and functions
  9. of the *Icl*. Synoptical tables allow to review the overall structure of
  10. the libraries design and to focus on structural equalities and differences
  11. with the corresponding containers of the standard template library.
  12. [section Class templates]
  13. [section Intervals]
  14. In the *icl* we have two groups of interval types. There are ['*statically bounded*] intervals,
  15. __ro_itv__,
  16. __lo_itv__,
  17. __cl_itv__,
  18. __op_itv__,
  19. that always have the the same kind of interval borders and ['*dynamically bounded*] intervals,
  20. __dc_itv__,
  21. __ct_itv__
  22. which can have one of the four possible bound types at runtime.
  23. [table Interval class templates
  24. [[group] [form] [template] [instance parameters]]
  25. [[statically bounded] [asymmetric][__ro_itv__] [`<class DomainT, template<class>class Compare>`]]
  26. [[ ] [] [__lo_itv__] [`<...same for all interval class templates...>`]]
  27. [[ ] [symmetric] [__cl_itv__] []]
  28. [[ ] [] [__op_itv__] []]
  29. [[dynamically bounded][] [__dc_itv__] []]
  30. [[ ] [] [__ct_itv__] []]
  31. ]
  32. Not every class template works with all domain types. Use interval class templates
  33. according the next table.
  34. [table Usability of interval class templates for discrete or continuous domain types
  35. [[group] [form] [template] [discrete] [continuous] ]
  36. [[statically bounded] [asymmetric][__ro_itv__] [yes] [yes] ]
  37. [[ ] [] [__lo_itv__] [yes] [yes] ]
  38. [[ ] [symmetric] [__cl_itv__] [yes] [ ] ]
  39. [[ ] [] [__op_itv__] [yes] [ ] ]
  40. [[dynamically bounded][] [__dc_itv__] [yes] [ ] ]
  41. [[ ] [] [__ct_itv__] [] [yes] ]
  42. ]
  43. From a pragmatical point of view, the most important interval class template
  44. of the /statically bounded/ group is __ro_itv__. For discrete domain types
  45. also closed intervals might be convenient. Asymmetric intervals can be used
  46. with continuous domain types but __ct_itv__ is the only class template that
  47. allows to represent a singleton interval that contains only one element.
  48. Use __ct_itv__, if you work with interval containers of countinuous domain types
  49. and you want to be able to handle single values:
  50. ``
  51. typedef interval_set<std::string, std::less, continuous_interval<std::string> > IdentifiersT;
  52. IdentifiersT identifiers, excluded;
  53. identifiers += continuous_interval<std::string>::right_open("a", "c");
  54. // special identifiers shall be excluded
  55. identifiers -= std::string("boost");
  56. cout << "identifiers: " << identifiers << endl;
  57. excluded = IdentifiersT(icl::hull(identifiers)) - identifiers;
  58. cout << "excluded : " << excluded << endl;
  59. //------ Program output: --------
  60. identifiers: {[a,boost)(boost,c)}
  61. excluded : {[boost,boost]}
  62. ``
  63. [h4 Library defaults and class template `interval`]
  64. As shown in the example above, you can choose an interval type
  65. by instantiating the interval container template with the desired type.
  66. ``
  67. typedef interval_set<std::string, std::less, continuous_interval<std::string> > IdentifiersT;
  68. ``
  69. But you can work with the library default for interval template parameters as well,
  70. which is `interval<DomainT,Compare>::type`.
  71. [table
  72. [[] [interval bounds][domain_type][interval_default]]
  73. [[`#ifdef` BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS][static] [ ] [__ro_itv__] ]
  74. [[`#else`] [dynamic] [discrete] [__dc_itv__] ]
  75. [[ ] [ ] [continuous] [__ct_itv__] ]
  76. ]
  77. So, if you are always happy with the library default for the interval type, just use
  78. ``
  79. icl::interval<MyDomainT>::type myInterval;
  80. ``
  81. as you standard way of declaring intervals and default parameters for interval containers:
  82. ``
  83. typedef interval_set<std::string> IdentifiersT;
  84. IdentifiersT identifiers, excluded;
  85. identifiers += interval<std::string>::right_open("a", "c");
  86. . . .
  87. ``
  88. So class template __itv__ provides a standard way to work with the library default
  89. for intervals. Via `interval<D,C>::type` you can declare a default interval.
  90. In addition four static functions
  91. ``
  92. T interval<D,C>::right_open(const D&, const D&);
  93. T interval<D,C>::left_open(const D&, const D&);
  94. T interval<D,C>::closed(const D&, const D&);
  95. T interval<D,C>::open(const D&, const D&);
  96. ``
  97. allow to construct intervals of the library default `T = interval<D,C>::type`.
  98. If you
  99. ``
  100. #define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
  101. ``
  102. the library uses only statically bounded __ro_itv__ as default interval type.
  103. In this case, the four static functions above are also available,
  104. but they only move interval borders consistently, if
  105. their domain type is discrete, and create an appropriate __ro_itv__ finally:
  106. ``
  107. interval<D,C>::right_open(a,b) == [a, b) -> [a , b )
  108. interval<D,C>:: left_open(a,b) == (a, b] -> [a++, b++)
  109. interval<D,C>:: closed(a,b) == [a, b] -> [a , b++)
  110. interval<D,C>:: open(a,b) == (a, b) -> [a++, b )
  111. ``
  112. For continuous domain types only the first of the four functions is applicable
  113. that matches the library default for statically bounded intervals: __ro_itv__.
  114. The other three functions can not perform an appropriate tranformation and
  115. will not compile.
  116. [endsect][/ Intervals]
  117. [section Sets]
  118. The next two tables give an overview over ['*set class templates*] of
  119. the icl.
  120. [/ interval_set]
  121. [/ separate_interval_set]
  122. [/ split_interval_set]
  123. [/ icl::set]
  124. [table Set class templates
  125. [[group] [template] [instance parameters]]
  126. [/ CL [__itv__] [__itv__] [`<DomainT,Compare>`]]
  127. [[__itv_bsets__][__itv_set__] [`<DomainT,Compare,IntervalT,Alloc>`]]
  128. [[] [__sep_itv_set__][`<DomainT,Compare,IntervalT,Alloc>`]]
  129. [[] [__spl_itv_set__][`<DomainT,Compare,IntervalT,Alloc>`]]
  130. [/ [__std_set__] [`std::set`] [`<_Key, _Compare, _Alloc>`]]
  131. ]
  132. Templates and template parameters, given in the preceding table are
  133. described in detail below.
  134. __Itv_bsets__ represent three
  135. class templates __itv_set__, __sep_itv_set__ and __spl_itv_set__
  136. that all have equal template parameters.
  137. [table Parameters of set class templates
  138. [[] [type of elements][order of elements] [type of intervals] [memory allocation]]
  139. [[template parameter] [`class`] [`template <class>class`] [`class`] [`template <class>class`]]
  140. [[__itv__] [`DomainT`][`Compare = std::less`] [] []]
  141. [[__itv_bsets__] [`DomainT`][`Compare = std::less`] [`IntervalT = interval<DomainT,Compare>::type`] [`Alloc = std::alloc`]]
  142. [/ [__icl_set__] [`DomainT`][`Compare = std::less`] [] [`Alloc = std::alloc`]]
  143. [/ [template parameter] [`class`] [`class`] [`class`] [class]]
  144. [/ [__std_set__] [`_Key`] [`_Compare = std::less<_Key>`][] [`Alloc = std::alloc<_Key>`]]
  145. ]
  146. [endsect][/ Sets]
  147. [section Maps]
  148. The next two tables give an overview over ['*map class templates*] of the icl.
  149. [/ interval_map]
  150. [/ split_interval_map]
  151. [/ icl::map]
  152. [table map class templates
  153. [[group] [template] [instance parameters]]
  154. [[__itv_bmaps__][__itv_map__] [`<DomainT,CodomainT,Traits,Compare,Combine,Section,IntervalT,Alloc>`]]
  155. [[] [__spl_itv_map__][`<DomainT,CodomainT,Traits,Compare,Combine,Section,IntervalT,Alloc>`]]
  156. [[__icl_map__] [__icl_map__] [`<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>`]]
  157. [/ [__std_map__] [__std_map__] [`<_Key, _Data, _Compare, _Alloc>`]]
  158. ]
  159. Templates and template parameters, given in the preceding table are
  160. described in detail below.
  161. __Itv_bmaps__ represent two
  162. class templates __itv_map__ and __spl_itv_map__
  163. that all have equal template parameters.
  164. [table Parameters of map class templates
  165. [[] [elements][mapped values][traits] [order of elements] [aggregation propagation] [intersection propagation] [type of intervals] [memory allocation]]
  166. [[template parameter] [`class`] [`class`] [`class`] [`template <class>class`] [`template <class>class`] [`template <class>class`] [`class`] [`template <class>class`]]
  167. [[__itv_bmaps__] [`DomainT`][`CodomainT`] [`Traits = identity_absorber`] [`Compare = std::less`] [`Combine = inplace_plus`] [`Section = icl::inplace_et`] [`IntervalT = interval<DomainT,Compare>::type`][`Alloc = std::alloc`]]
  168. [[__icl_map__] [`DomainT`][`CodomainT`] [`Traits = identity_absorber`] [`Compare = std::less`] [`Combine = inplace_plus`] [`Section = icl::inplace_et`] [`Alloc = std::alloc`]]
  169. [/ [template parameter] [`class`] [`class`] [] [`class`] [] [] [] [`class`]]
  170. [/ [__std_map__] [`_Key`] [`_Data`] [] [`_Compare = std::less<_Key>`][] [] [] [`Alloc = std::alloc<_Key>`]]
  171. ]
  172. Using the following placeholders,
  173. ``
  174. D := class DomainT,
  175. C := class CodomainT,
  176. T := class Traits,
  177. cp := template<class D>class Compare = std::less,
  178. cb := template<class C>class Combine = icl::inplace_plus,
  179. s := template<class C>class Section = icl::inplace_et,
  180. I := class IntervalT = icl::interval<D,cp>::type
  181. a := template<class>class Alloc = std::allocator
  182. ``
  183. we arrive at a final synoptical matrix of class templates and their parameters.
  184. [pre
  185. interval <D, cp, >
  186. interval_sets<D, cp, I, a >
  187. interval_maps<D, C, T, cp, cb, s, I, a >
  188. icl::map <D, C, T, cp, cb, s, a >
  189. ]
  190. The choice of parameters and their positions follow the std::containers
  191. as close a possible, so that usage of interval sets and maps does only
  192. require minimal additional knowledge.
  193. Additional knowledge is required when instantiating a comparison parameter
  194. `Compare` or an allocation parameter `Alloc`. In contrast to std::containers
  195. these have to be instantiated as templates, like e.g.
  196. ``
  197. interval_set<string, german_compare> sections; // 2nd parameter is a template
  198. std::set<string, german_compare<string> > words; // 2nd parameter is a type
  199. ``
  200. [endsect][/ Maps]
  201. [endsect][/ Class templates]
  202. [section Required Concepts]
  203. There are uniform requirements for the template parameters
  204. across *icl's* class templates. The template parameters can
  205. be grouped with respect to those requirements.
  206. [table
  207. [[] [used in] [Kind] [Parameter] [Instance] [Description] ]
  208. [[Domain order] [`Intervals, Sets, Maps`][`typename`][`DomainT`] [] [For the type `DomainT` of key elements `...`]]
  209. [[] [] [`template`] [`Compare`] [`Compare<DomainT>`] [`...` there is an order `Compare`] ]
  210. [[Interval type] [`interval_sets/maps`][`typename`] [`IntervalT`] [] [`...` the `IntervalT` parameter has to use the same element type and order. ] ]
  211. [[Codomain aggregation][`Maps`] [`typename`] [`CodomainT`] [] [For the type `CodomainT` of associated values `...`]]
  212. [[] [] [`template`] [`Combine`] [`Combine<CodomainT>`] [`...` there is a binary functor `Combine<CodomainT>()` to combine them ] ]
  213. [[] [] [] [] [`Inverse<Combine<CodomainT>>`][`...` and implicitly an `Inverse` functor to inversely combine them. ] ]
  214. [[] [] [`template`] [`Section`] [`Section<CodomainT>`] [Intersection is propagated to CodomainT values via functor `Section<CodomainT>()`] ]
  215. [[Memory allocation] [`Sets, Maps`] [`template`] [`Alloc`] [`Alloc<`/various/`>`] [An allocator can be chosen for memory allocation.]]
  216. ]
  217. [/ table
  218. [[Kind] [Parameter] [Condition] [Requirement] ]
  219. [[`typename`][`DomainT`] [] [`Regular<DomainT> && LessThanComparable<DomainT,Compare>`
  220. `&& (IsIncrementable<DomainT>||HasUnitElement<DomainT>)`] ]
  221. [[][] [`IsIntegral<DomainT>`] [`IsIncrementable<DomainT> && IsDecrementable<DomainT>`] ]
  222. [[`typename`][`CodomainT`][`Combine` and `Inverse<Combine>` unused] []]
  223. [[][] [only `Combine` used ] [`EqualityComparable<CodomainT> && Addable<CodomainT,Combine>`] ]
  224. [[][] [also `Inverse<Combine>` used] [`&& Subtractable<CodomainT,Inverse<Combine> >`] ]
  225. [[`template`][`Compare`] [] [`LessThanComparable<DomainT,Compare>`] ]
  226. [[`template`][`Combine`] [only `Combine` used] [`Addable<CodomainT,Combine>`]]
  227. [[][] [and `Inverse<Combine>` used] [`&& Subtractable<CodomainT,Inverse<Combine> >`] ]
  228. [[][] [`Section` used and `CodomainT` is a set][`Intersectable<CodomainT,Section>`] ]
  229. ]
  230. [h4 Requirements on DomainT]
  231. The next table gives an overview over the requirements for
  232. template parameter `DomainT`. Some requirements are dependent
  233. on /conditions/. Column /operators/ shows the operators and
  234. functions that are expected for `DomainT`, if the default order
  235. `Compare = std::less` is used.
  236. [table
  237. [[Parameter] [Condition] [Operators] [Requirement] ]
  238. [[`DomainT`] [] [`DomainT(), <`] [`Regular<DomainT> && StrictWeakOrdering<DomainT,Compare>`]]
  239. [[] [] [`++, unit_element<CodomainT>::value()`][`&& (IsIncrementable<DomainT>||HasUnitElement<DomainT>)`] ]
  240. [[] [`IsIntegral<DomainT>`][`++, --`] [`IsIncrementable<DomainT> && IsDecrementable<DomainT>`] ]
  241. ]
  242. A domain type `DomainT` for intervals and interval containers
  243. has to satisfy the requirements of concept
  244. [@http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=314 `Regular`]
  245. which
  246. implies among other properties the existence of a copy and
  247. a default constructor. In addition `IsIncrementable`
  248. *or* `HasUnitElement` is required for `DomainT`.
  249. In the *icl* we represent an empty closed interval as
  250. interval `[b,a]` where `a < b` (here `<` represents `Compare<DomainT>()`).
  251. To construct one of these empty intervals as default constructor
  252. for any type `DomainT` we choose `[1,0]`, where `0` is a null-value or `identity_element`
  253. and `1` is a one-value or `unit_element`:
  254. ``
  255. interval() := [unit_element<DomainT>::value(), identity_element<DomainT>::value()] //pseudocode
  256. ``
  257. `Identity_elements` are implemented via call of the default constructor of
  258. `DomainT`. A `unit_element<T>::value()` is implemented
  259. [classref boost::icl::unit_element by default] as a `identity_element`,
  260. that is incremented once.
  261. ``
  262. template <class Type>
  263. inline Type unit_element<Type>::value(){ return succ(identity_element<Type>::value()); };
  264. ``
  265. So a type `DomainT` that is `incrementable` will
  266. also have an `unit_element`. If it does not, a `unit_element` can be provided.
  267. A `unit_element` can be any value, that is greater as the `identity_element`
  268. in the `Compare` order given.
  269. An example of a type, that has an `identity_element` but no increment operation is
  270. `string`. So for `std::string` a unit_element is implemented like this:
  271. ``
  272. // Smallest 'visible' string that is greater than the empty string.
  273. template <>
  274. inline std::string unit_element<std::string>::value(){ return std::string(" "); };
  275. ``
  276. Just as for the key type of std::sets and maps
  277. template parameter `Compare` is required to be a
  278. [@http://en.wikipedia.org/wiki/Strict_weak_ordering strict weak ordering] on `DomainT`.
  279. Finally, if `DomainT` is an integral type, `DomainT` needs to
  280. be `incrementable` and `decrementable`. This [''bicrementability']
  281. needs to be implemented on the smallest possible unit of the
  282. integral type. This seems like being trivial but there are types like e.g.
  283. `boost::date_time::ptime`, that are integral in nature but do
  284. not provide the required in- and decrementation on the least incrementable unit.
  285. For __icl_itvs__ incementation and decementation is used
  286. for computations between open to closed interval borders like e.g.
  287. `[2,43) == [2,42]`. Such computations always need only
  288. one in- or decrementation, if `DomainT` is an integral type.
  289. [h5 Requirements on IntervalT]
  290. Requirements on the `IntervalT` parameter are closely related to the
  291. `DomainT` parameter. `IntervalT` has two associated types
  292. itself for an element type and a compare order that have
  293. to be consistent with the element and order parameters of
  294. their interval containers.
  295. `IntervalT` then has to implement an order called
  296. `exclusive_less`. Two intervals `x, y` are exclusive_less
  297. ``icl::exclusive_less(x, y)``
  298. if all `DomainT` elements of `x` are less than elements of `y` in the
  299. `Compare` order.
  300. [table
  301. [[Parameter] [Operators] [Requirement] ]
  302. [[`IntervalT`] [`exclusive_less`] [`IsExclusiveLessComparable<Interval<DomainT,Compare> >`] ]
  303. ]
  304. [h4 Requirements on CodomainT]
  305. Summarized in the next table are requirements for template parameter
  306. `CodomainT` of associated values for `Maps`. Again there are
  307. /conditions/ for some of the requirements. Column /operators/
  308. contains the operators and functions required for `CodomainT`, if we are
  309. using the default combiner `Combine = icl::inplace_plus`.
  310. [table
  311. [[Parameter] [Condition] [Operators] [Requirement] ]
  312. [[`CodomainT`][`add`, `subtract`, `intersect` unused] [`CodomainT(), ==`][`Regular<CodomainT>` which implies] ]
  313. [[] [] [] [`DefaultConstructible<CodomainT> && EqualityComparable<CodomainT>`] ]
  314. [[] [only `add` used ] [`+=`] [`&& Combinable<CodomainT,Combine>`] ]
  315. [[] [... and also `subtract` used] [`-=`] [`&& Combinable<CodomainT,Inverse<Combine> >`]]
  316. [[] [`Section` used and `CodomainT` is a set][`&=`] [`&& Intersectable<CodomainT,Section>`] ]
  317. ]
  318. The requirements on the type `CodomainT` of associated values for a __icl_map__ or __itv_map__
  319. depend on the usage of their aggregation functionality. If aggregation on overlap
  320. is never used, that is to say that none of the addition, subtraction and intersection
  321. operations (`+, +=, add`, `-, -=, subtract`, &, &=, add_intersection) are used on the
  322. __itv_map__, then `CodomainT` only needs to be
  323. [@http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=314 Regular].
  324. ['*Regular*]
  325. object semantics implies `DefaultConstructible` and
  326. `EqualityComparable` which means it has
  327. a default ctor `CodomainT()` and an `operator ==`.
  328. Use __itv_maps__ ['*without aggregation*], if the associated values are not
  329. addable but still
  330. are attached to intervals so you want to use __itv_maps__ to handle them.
  331. As long as those values are added with `insert` and deleted with `erase`
  332. __itv_maps__ will work fine with such values.
  333. If ['*only addition*] is used via __itv_map_s__ `+, +=` or `add` but no subtraction,
  334. then `CodomainT` need to be `Combinable` for functor template `Combine`. That
  335. means in most cases when the default implementation `inplace_plus` for
  336. `Combine` is used, that `CodomainT` has to implement `operator +=`.
  337. For associated value types, that are addable but not subtractable like
  338. e.g. `std::string` it usually makes sense to use addition to combine values
  339. but the inverse combination is not desired.
  340. ``
  341. interval_map<int,std::string> cat_map;
  342. cat_map += make_pair(interval<int>::rightopen(1,5),std::string("Hello"));
  343. cat_map += make_pair(interval<int>::rightopen(3,7),std::string(" world"));
  344. cout << "cat_map: " << cat_map << endl;
  345. //cat_map: {([1,3)->Hello)([3,5)->Hello world)([5,7)-> world)}
  346. ``
  347. For ['complete aggregation functionality] an inverse aggregation functor on
  348. a `Map`'s `CodomainT` is needed. The icl provides a
  349. metafunction [classref boost::icl::inverse inverse]
  350. for that purpose. Using the default
  351. `Combine = inplace_plus` that relies on the existence of `operator +=`
  352. on type `CodomainT`
  353. metafunction [classref boost::icl::inverse inverse]
  354. will infer [classref boost::icl::inplace_minus inplace_minus]
  355. as inverse functor, that requires `operator -=` on type `CodomainT`.
  356. In the icl's design we make the assumption,
  357. in particular for the default setting of parameters
  358. `Combine = `[classref boost::icl::inplace_minus inplace_plus],
  359. that type `CodomainT` has a neutral element or `identity_element`
  360. with respect to the `Combine` functor.
  361. [endsect][/ Required Concepts]
  362. [section Associated Types]
  363. In order to give an overview over ['*associated types*] the *icl* works
  364. with, we will apply abbreviations again that were introduced in the
  365. presentaiton of icl class templates,
  366. [pre
  367. interval <D, cp, >
  368. interval_sets<D, cp, I, a >
  369. interval_maps<D, C, T, cp, cb, s, I, a >
  370. icl::map <D, C, T, cp, cb, s, a >
  371. ]
  372. where these placeholders were used:
  373. ``
  374. D := class DomainT,
  375. C := class CodomainT,
  376. T := class Traits,
  377. cp := template<class D>class Compare = std::less,
  378. cb := template<class C>class Combine = icl::inplace_plus,
  379. s := template<class C>class Section = icl::inplace_et,
  380. I := class Interval = icl::interval<D,cp>::type
  381. a := template<class>class Alloc = std::allocator
  382. ``
  383. With some additions,
  384. ``
  385. sz := template<class D>class size
  386. df := template<class D>class difference
  387. Xl := class ExclusiveLess = exclusive_less<Interval<DomainT,Compare> >
  388. inv:= template<class Combiner>class inverse
  389. (T,U) := std::pair<T,U> for typnames T,U
  390. ``
  391. we can summarize the associated types as follows.
  392. Again two additional columns for easy comparison with stl
  393. sets and maps are provided.
  394. [table Icl Associated types
  395. [[Purpose] [Aspect] [Type][__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  396. [/[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] ]
  397. [/ interval itvset itvmap icl:set icl:map ]
  398. [[['*Data*]] [__conceptual__] [`domain_type`] [`D`] [`D`] [`D`] [`D`] [`D`] ]
  399. [[ ] [ ] [`codomain_type`] [`D`] [`D`] [`C`] [`D`] [`C`] ]
  400. [[ ] [ ] [`element_type`] [`D`] [`D`] [`(D,C)`] [`D`] [`(D,C)`] ]
  401. [[ ] [ ] [`segment_type`][`i<D,cp>`][`i<D,cp>`][`(i<D,cp>,C)`][ ] [ ] ]
  402. [[ ] [['size] ] [`size_type`] [`sz<D>`][`sz<D>`][`sz<D>`] [`sz<D>`] [`sz<D>`] ]
  403. [[ ] [ ] [`difference_type`] [`df<D>`][`df<D>`][`df<D>`] [`sz<D>`] [`sz<D>`] ]
  404. [[ ] [ ] [][__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  405. [[['*Data*]] [__iterative__ ] [`key_type`] [`D`][`i<D,cp>`][`i<D,cp>`] [`D`] [`D`] ]
  406. [[ ] [ ] [`data_type`] [`D`][`i<D,cp>`] [`C`] [`D`] [`C`] ]
  407. [[ ] [ ] [`value_type`] [`D`][`i<D,cp>`][`(i<D,cp>,C)`][`D`][`(D,C)`]]
  408. [[ ] [ ] [`interval_type`] [`i<D,cp>`][`i<D,cp>`][`i<D,cp>`] [ ] [ ] ]
  409. [[ ] [['allocation]] [`allocator_type`] [ ][`a<i<D,cp>>`][`a<(i<D,cp>, C)>`][`a<D>`][`a<(D,C)>`]]
  410. [[ ] [ ] [][__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  411. [[['*Ordering*]] [__conceptual__] [`domain_compare`] [`cp<D>`][`cp<D>`][`cp<D>`][`cp<D>`][`cp<D>`] ]
  412. [[ ] [__iterative__ ] [`key_compare`] [`cp<D>`] [`Xl`] [`Xl`] [`cp<D>`] [`cp<D>`] ]
  413. [[ ] [ ] [`interval_compare`] [ ] [`Xl`] [`Xl`] [ ] [ ] ]
  414. [[['*Aggregation*]] [__conceptual__] [`codomain_combine`] [ ] [ ] [`cb<C>`] [ ] [`cb<C>`] ]
  415. [[ ] [ ] [`inverse_codomain_combine`] [ ] [ ][`inv<cb<C>>`] [ ][`inv<cb<C>>`] ]
  416. [[ ] [ ] [`codomain_intersect`] [ ] [ ] [`s<C>`] [ ] [`s<C>`] ]
  417. [[ ] [ ] [`inverse_codomain_intersect`] [ ] [ ] [`inv<s<C>>`] [ ][`inv<s<C>>`] ]
  418. ]
  419. [endsect][/ Associated Types]
  420. [section Function Synopsis]
  421. In this section a single ['*matrix*] is given, that shows all ['*functions*]
  422. with shared names and identical or analogous semantics and their
  423. polymorphic overloads across the class templates of the *icl*.
  424. In order to achieve a concise representation, a series
  425. of ['*placeholders*] are used throughout the function matrix.
  426. The ['*placeholder's*] purpose is to express the polymorphic
  427. usage of the functions. The ['*first column*] of the function matrix
  428. contains the signatures of the functions. Within these
  429. signatures `T` denotes a container type and `J` and `P`
  430. polymorphic argument and result types.
  431. Within the body of the matrix, sets of *boldface* placeholders denote
  432. the sets of possible instantiations for a polymorphic
  433. placeholder `P`. For instance __eiS denotes that for the
  434. argument type `P`, an element __e, an interval __i or an interval_set __S
  435. can be instantiated.
  436. If the polymorphism can not be described in this way, only the ['*number*] of
  437. overloaded implementations for the function of that row is shown.
  438. [table
  439. [[Placeholder] [Argument types] [Description]]
  440. [[`T` ] [] [a container or interval type]]
  441. [[`P` ] [] [polymorphic container argument type]]
  442. [[`J` ] [] [polymorphic iterator type]]
  443. [[`K` ] [] [polymorphic element_iterator type for interval containers]]
  444. [[`V` ] [] [various types `V`, that do dot fall in the categories above]]
  445. [[1,2,... ] [] [number of implementations for this function]]
  446. [[A ] [] [implementation generated by compilers]]
  447. [[[#element_type] [*e]] [T::element_type] [the element type of __itv_sets__ or __icl_sets__]]
  448. [[[#interval_type] [*i]] [T::segment_type] [the segment type of of __itv_sets__]]
  449. [[[#itl_set_type] [*s]] [element sets] [__std_set__ or other models of the icl's set concept]]
  450. [[[#interval_set_types] [*S]] [interval_sets] [one of the interval set types]]
  451. [[[#element_mapping_type] [*b]] [T::element_type] [type of __itv_map_s__ or __icl_map_s__ element value pairs]]
  452. [[[#interval_mapping_type][*p]] [T::segment_type] [type of __itv_map_s__ interval value pairs]]
  453. [[[#itl_map_type] [*m]] [element maps] [__icl_map__ icl's map type]]
  454. [[[#interval_map_types] [*M]] [interval_maps] [one of the interval map types]]
  455. [[[#discrete_types] [*d]] [discrete types] [types with a least steppable discrete unit: Integral types, date/time types etc.]]
  456. [[[#continuous_types] [*c]] [continuous types] [types with (theoretically) infinitely many elements beween two values.]]
  457. ]
  458. [/ memberref boost::icl::set::iterative_size `iterative_size`]
  459. [table Synopsis Functions and Overloads
  460. [[T] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  461. [/ interval itvset itvmap icl:set icl:map ]
  462. [[__biLConsCopyDest__ [#function_synopsis_table]] [ ] [ ] [ ] [ ] [ ] ]
  463. [[`T::T()`] [1] [1] [1] [1] [1] ]
  464. [[`T::T(const P&)`] [A] [__eiS] [__bpM] [1] [1] ]
  465. [/ FYI [`T::T(...)`] [3] [ ] [ ] [3] [3] ]
  466. [[`T& T::operator=(const P&)`] [A] [__S] [__M] [1] [1] ]
  467. [[`void T::swap(T&)`] [ ] [1] [1] [1] [1] ]
  468. [[__biLContainedness__ ][__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  469. [[`bool T::empty()const`] [ ] [1] [1] [1] [1] ]
  470. [[`bool is_empty(const T&)`] [1] [1] [1] [1] [1] ]
  471. [[`bool contains(const T&, const P&)`\n
  472. `bool within(const P&, const T&)`] [__ei] [__eiS][__eiS __bpM][__es] [__bm] ]
  473. [[__biLEquivsOrderings__ ][__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  474. [[`bool operator == (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  475. [[`bool operator != (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  476. [[`bool operator < (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  477. [[`bool operator > (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  478. [[`bool operator <= (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  479. [[`bool operator >= (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  480. [[`bool is_element_equal(const T&, const P&)`] [ ] [__S] [__M] [1] [1] ]
  481. [[`bool is_element_less(const T&, const P&)`] [ ] [__S] [__M] [1] [1] ]
  482. [[`bool is_element_greater(const T&, const P&)`] [ ] [__S] [__M] [1] [1] ]
  483. [[`bool is_distinct_equal(const T&, const P&)`] [ ] [ ] [__M] [ ] [1] ]
  484. [[__biLSize__ ] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  485. [[`size_type T::size()const`] [ ] [1] [1] [1] [1] ]
  486. [[`size_type size(const T&)`] [1] [1] [1] [1] [1] ]
  487. [[`size_type cardinality(const T&)`] [1] [1] [1] [1] [1] ]
  488. [[`difference_type length(const T&)`] [1] [1] [1] [ ] [ ] ]
  489. [[`size_type iterative_size(const T&)`] [ ] [1] [1] [1] [1] ]
  490. [[`size_type interval_count(const T&)`] [ ] [1] [1] [ ] [ ] ]
  491. [[__biLSelection__ ] [ ] [ ] [ ] [ ] [ ] ]
  492. [[`J T::find(const P&)`] [ ] [__ei] [__ei] [2] [2] ]
  493. [[`J find(T&, const P&)`] [ ] [__ei] [__ei] [ ] [ ] ]
  494. [[`codomain_type& operator[] (const domain_type&)`][ ] [ ] [ ] [ ] [1] ]
  495. [[`codomain_type operator() (const domain_type&)const`][ ] [ ] [1] [ ] [1] ]
  496. [[__biLRange__] [ ] [ ] [ ] [ ] [ ] ]
  497. [[`interval_type hull(const T&)`] [ ] [1] [1] [ ] [ ] ]
  498. [[`T hull(const T&, const T&)`] [1] [ ] [ ] [ ] [ ] ]
  499. [[`domain_type lower(const T&)`] [1] [1] [1] [ ] [ ] ]
  500. [[`domain_type upper(const T&)`] [1] [1] [1] [ ] [ ] ]
  501. [[`domain_type first(const T&)`] [1] [1] [1] [ ] [ ] ]
  502. [[`domain_type last(const T&)`] [1] [1] [1] [ ] [ ] ]
  503. [[__biLAddition__] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  504. [[`T& T::add(const P&)`] [ ] [__ei] [__bp] [ ] [__b] ]
  505. [[`T& add(T&, const P&)`] [ ] [__ei] [__bp] [__e] [__b] ]
  506. [[`J T::add(J pos, const P&)`] [ ] [__i] [__p] [ ] [__b] ]
  507. [[`J add(T&, J pos, const P&)`] [ ] [__i] [__p] [__e] [__b] ]
  508. [[`T& operator +=(T&, const P&)`] [ ] [__eiS] [__bpM] [__es] [__bm] ]
  509. [[`T operator + (T, const P&)`\n
  510. `T operator + (const P&, T)`]
  511. [ ] [__eiS] [__bpM] [__es] [__bm] ]
  512. [[`T& operator |=( T&, const P&)`] [ ] [__eiS] [__bpM] [__es] [__bm] ]
  513. [[`T operator | (T, const P&)`\n
  514. `T operator | (const P&, T)`]
  515. [ ] [__eiS] [__bpM] [__es] [__bm] ]
  516. [[__biLSubtraction__] [ ] [ ] [ ] [ ] [ ] ]
  517. [[`T& T::subtract(const P&)`] [ ] [__ei] [__bp] [ ] [__b] ]
  518. [[`T& subtract(T&, const P&)`] [ ] [__ei] [__bp] [__e] [__b] ]
  519. [[`T& operator -=(T&, const P&)`] [ ] [__eiS][__eiS __bpM][__es] [__bm] ]
  520. [[`T operator - (T, const P&)`] [ ] [__eiS][__eiS __bpM][__es] [__bm] ]
  521. [[`T left_subtract(T, const T&)`] [1] [ ] [ ] [ ] [ ] ]
  522. [[`T right_subtract(T, const T&)`] [1] [ ] [ ] [ ] [ ] ]
  523. [[__biLInsertion__] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  524. [[`V T::insert(const P&)`] [ ] [__ei] [__bp] [__e] [__b] ]
  525. [[`V insert(T&, const P&)`] [ ] [__ei] [__bp] [__e] [__b] ]
  526. [[`J T::insert(J pos, const P&)`] [ ] [__i] [__p] [__e] [__b] ]
  527. [[`J insert(T&, J pos, const P&)`] [ ] [__i] [__p] [__e] [__b] ]
  528. [[`T& insert(T&, const P&)`] [ ] [__eiS] [__bpM] [__es] [__bm] ]
  529. [[`T& T::set(const P&)`] [ ] [ ] [__bp] [ ] [1] ]
  530. [[`T& set_at(T&, const P&)`] [ ] [ ] [__bp] [ ] [1] ]
  531. [[__biLErasure__] [ ] [ ] [ ] [ ] [ ] ]
  532. [[`void T::clear()`] [ ] [1] [1] [1] [1] ]
  533. [[`void clear(const T&)`] [ ] [1] [1] [1] [1] ]
  534. [[`T& T::erase(const P&)`] [ ] [__ei ] [__ei __bp] [__e] [__bp] ]
  535. [[`T& erase(T&, const P&)`] [ ] [__eiS][__eiS __bpM][__es] [__bm] ]
  536. [[`void T::erase(iterator)`] [ ] [1] [1] [1] [1] ]
  537. [[`void T::erase(iterator,iterator)`] [ ] [1] [1] [1] [1] ]
  538. [[__biLIntersection__] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  539. [[`void add_intersection(T&, const T&, const P&)`][ ] [__eiS][__eiS __bpM][ ] [ ] ]
  540. [[`T& operator &=(T&, const P&)`] [ ] [__eiS][__eiS __bpM][__es] [__bm] ]
  541. [[`T operator & (T, const P&)`\n
  542. `T operator & (const P&, T)`] [__i] [__eiS][__eiS __bpM][__es] [__bm] ]
  543. [[`bool intersects(const T&, const P&)`\n
  544. `bool disjoint(const T&, const P&)`] [__i] [__eiS][__eiS __bpM][__es] [__bm] ]
  545. [[__biLSymmetricDifference__] [ ] [ ] [ ] [ ] [ ] ]
  546. [[`T& T::flip(const P&)`] [ ] [__ei] [__bp] [ ] [__b] ]
  547. [[`T& flip(T&, const P&)`] [ ] [__ei] [__bp] [__e] [__b] ]
  548. [[`T& operator ^=(T&, const P&)`] [ ] [__eiS] [__bpM] [__es] [__bm] ]
  549. [[`T operator ^ (T, const P&)`\n
  550. `T operator ^ (const P&, T)`] [ ] [__eiS] [__bpM] [__es] [__bm] ]
  551. [[__biLIteratorRelated__] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  552. [[`J T::begin()`] [ ] [2] [2] [2] [2] ]
  553. [[`J T::end()`] [ ] [2] [2] [2] [2] ]
  554. [[`J T::rbegin()`] [ ] [2] [2] [2] [2] ]
  555. [[`J T::rend()`] [ ] [2] [2] [2] [2] ]
  556. [[`J T::lower_bound(const key_type&)`] [ ] [2] [2] [2] [2] ]
  557. [[`J T::upper_bound(const key_type&)`] [ ] [2] [2] [2] [2] ]
  558. [[`pair<J,J> T::equal_range(const key_type&)`] [ ] [2] [2] [2] [2] ]
  559. [[__biLElementIteration__] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  560. [[`K elements_begin(T&)`] [ ] [2] [2] [ ] [ ] ]
  561. [[`K elements_end(T&)`] [ ] [2] [2] [ ] [ ] ]
  562. [[`K elements_rbegin(T&)`] [ ] [2] [2] [ ] [ ] ]
  563. [[`K elements_rend(T&)`] [ ] [2] [2] [ ] [ ] ]
  564. [[__biLStreaming__ ] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  565. [[`std::basic_ostream operator << (basic_ostream&, const T&)`]
  566. [1] [1] [1] [1] [1] ]
  567. ]
  568. Many but not all functions of *icl* intervals are listed in the table above.
  569. Some specific functions are summarized in the next table. For the group of
  570. the constructing functions, placeholders __d denote discrete domain types and
  571. __c denote continuous domain types `T::domain_type` for an interval_type `T` and an
  572. argument types `P`.
  573. [table Additional interval functions
  574. [[T] [__ch_dsc_itv__] [__ch_cnt_itv__] [__ch_ro_itv__] [__ch_lo_itv__] [__ch_cl_itv__] [__ch_op_itv__] ]
  575. [[Interval bounds] [dynamic] [dynamic] [static] [static] [static] [static] ]
  576. [[Form] [ ] [ ] [asymmetric] [asymmetric] [symmetric] [symmetric] ]
  577. [[__biLIntervalConstruct__ [#additional_interval_functions]]
  578. [ ] [ ] [ ] [ ] [ ] [ ] ]
  579. [[`T singleton(const P&)`] [__d] [__c] [__d] [__d] [__d] [__d] ]
  580. [[`T construct(const P&, const P&)`] [__d] [__c] [__dc] [__dc] [__d] [__d] ]
  581. [[`T construct(const P&, const P&, interval_bounds)`] [__d] [__c] [ ] [ ] [ ] [ ] ]
  582. [[`T hull(const P&, const P&)`] [__d] [__c] [__dc] [__dc] [__d] [__d] ]
  583. [[`T span(const P&, const P&)`] [__d] [__c] [__dc] [__dc] [__d] [__d] ]
  584. [[`static T right_open(const P&, const P&)`] [__d] [__c] [ ] [ ] [ ] [ ] ]
  585. [[`static T left_open(const P&, const P&)`] [__d] [__c] [ ] [ ] [ ] [ ] ]
  586. [[`static T closed(const P&, const P&)`] [__d] [__c] [ ] [ ] [ ] [ ] ]
  587. [[`static T open(const P&, const P&)`] [__d] [__c] [ ] [ ] [ ] [ ] ]
  588. [[__biLIntervalOrderings__] [ ] [ ] [ ] [ ] [ ] [ ] ]
  589. [[`bool exclusive_less(const T&, const T&)`] [1] [1] [1] [1] [1] [1] ]
  590. [[`bool lower_less(const T&, const T&)`\n
  591. `bool lower_equal(const T&, const T&)`\n
  592. `bool lower_less_equal(const T&, const T&)`] [1] [1] [1] [1] [1] [1] ]
  593. [[`bool upper_less(const T&, const T&)`\n
  594. `bool upper_equal(const T&, const T&)`\n
  595. `bool upper_less_equal(const T&, const T&)`] [1] [1] [1] [1] [1] [1] ]
  596. [[__biLIntervalMiscellaneous__] [ ] [ ] [ ] [ ] [ ] [ ] ]
  597. [[`bool touches(const T&, const T&)`] [1] [1] [1] [1] [1] [1] ]
  598. [[`T inner_complement(const T&, const T&)`] [1] [1] [1] [1] [1] [1] ]
  599. [[`difference_type distance(const T&, const T&)`] [1] [1] [1] [1] [1] [1] ]
  600. ]
  601. [h4 Element iterators for interval containers]
  602. Iterators on [*interval conainers] that are refered to in section /Iteration/
  603. of the function synopsis table are
  604. ['*segment iterators*]. They reveal the more implementation specific
  605. aspect, that the __conceptual__ aspect abstracts from.[/ NOTE Identical to function_element_iteration.qbk from here]
  606. Iteration over segments is fast, compared to an iteration over elements,
  607. particularly if intervals are large.
  608. But if we want to view our interval containers as containers
  609. of elements that are usable with std::algoritms, we need to
  610. iterate over elements.
  611. Iteration over elements . . .
  612. * is possible only for integral or discrete `domain_types`
  613. * can be very ['*slow*] if the intervals are very large.
  614. * and is therefore ['*depreciated*]
  615. On the other hand, sometimes iteration over interval containers
  616. on the element level might be desired, if you have some
  617. interface that works for `std::SortedAssociativeContainers` of
  618. elements and you need to quickly use it with an interval container.
  619. Accepting the poorer performance might be less bothersome at times
  620. than adjusting your whole interface for segment iteration.
  621. [caution So we advice you to choose element iteration over
  622. interval containers ['*judiciously*]. Do not use element iteration
  623. ['*by default or habitual*]. Always try to achieve results using
  624. namespace global functions or operators
  625. (preferably inplace versions)
  626. or iteration over segments first.]
  627. [endsect][/ Function Synopsis]
  628. [endsect][/ Interface]