functions.qbk 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. [/
  2. Copyright (c) 2008-2009 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 Function Reference]
  8. Section [link boost_icl.interface.function_synopsis Function Synopsis]
  9. above gave an overview of the polymorphic functions of the icl.
  10. This is what you will need to find the desired possibilities to combine icl
  11. functions and objects most of the time.
  12. The functions and overloads that you intuitively expect
  13. should be provided, so you won't need to refer to the documentation very often.
  14. If you are interested
  15. * in the ['*specific design of the function overloads*],
  16. * in ['*complexity characteristics*] for certain overloads
  17. * or if the compiler ['*refuses to resolve*] specific function application you want to use,
  18. refer to this section that describes the polymorphic function families of the icl
  19. in detail.
  20. [h5 Placeholders]
  21. For a concise representation the same __eiS_phs__ will be used that have been
  22. introduced in section [link boost_icl.interface.function_synopsis Function Synopsis].
  23. [h5 More specific function documentation]
  24. This section covers the most important polymorphic and namespace global
  25. functions of the *icl*. More specific functions can be looked up
  26. in the doxygen generated
  27. [link interval_container_library_reference reference documentation].
  28. [section Overload tables]
  29. Many of the *icl's* functions are overloaded for
  30. elements, segments, element and interval containers.
  31. But not all type combinations are provided. Also
  32. the admissible type combinations are different for
  33. different functions and operations.
  34. To concisely represent the overloads that can be
  35. used we use synoptical tables that contain
  36. possible type combinations for an operation.
  37. These are called ['*overload tables*]. As an example
  38. the overload tables for the inplace intersection
  39. `operator &=` are given:
  40. ``
  41. // overload tables for
  42. T& operator &= (T&, const P&)
  43. element containers: interval containers:
  44. &= | e b s m &= | e i b p S M
  45. ---+-------- ---+------------
  46. s | s s S | S S S
  47. m | m m m m M | M M M M M M
  48. ``
  49. For the binary `T& operator &= (T&, const P&)` there are two
  50. different tables for the overloads of element and interval containers.
  51. The first argument type `T` is displayed as row headers
  52. of the tables.
  53. The second argument type `P` is displayed as column headers
  54. of the tables.
  55. If a combination of `T` and `P` is admissible the related
  56. cell of the table is non empty.
  57. It displays the result type of the operation. In this example
  58. the result type is always equal to the first argument.
  59. The possible types that can be instantiated for `T` and `P`
  60. are element, interval and container types abbreviated by
  61. placeholders that are defined
  62. [link boost_icl.interface.function_synopsis here]
  63. and can be summarized as
  64. __s : element set, __S : interval sets, __e : elements, __i : intervals\n
  65. __m:element map, __M:interval maps, __b:element-value pairs, __p:interval-value pairs
  66. [endsect][/ Overload tables]
  67. [section Segmentational Fineness]
  68. For overloading tables on infix operators, we need to
  69. break down __itv_sets__ and __itv_maps__ to the
  70. specific class templates
  71. [table
  72. [[][] [][] [][]]
  73. [[[#ph_def_S1][*S1]][__itv_set__][[#ph_def_S2][*S2]][__sep_itv_set__][[#ph_def_S3][*S3]][__spl_itv_set__]]
  74. [[[#ph_def_M1][*M1]][__itv_map__][][] [[#ph_def_M3][*M3]][__spl_itv_map__]]
  75. ]
  76. choosing *Si* and *Mi* as placeholders.
  77. The indices *i* of *Si* and *Mi* represent a property
  78. called ['*segmentational fineness*] or short ['*fineness*],
  79. which is a ['*type trait*] on interval containers.
  80. [table
  81. [[]]
  82. [[`segmentational_fineness<`[*Si]`>::value` == *i*]]
  83. [[`segmentational_fineness<`[*Mi]`>::value` == *i*]]
  84. ]
  85. Segmentational fineness represents the fact,
  86. that for interval containers holding the same elements, a
  87. splitting interval container may contain more segments as
  88. a separating container which in turn may contain more
  89. segments than a joining one. So for an
  90. ``
  91. operator >
  92. ``
  93. where
  94. ``
  95. x > y // means that
  96. x is_finer_than y
  97. // we have
  98. finer coarser
  99. split_interval_set interval_set
  100. > separate_interval_set >
  101. split_interval_map interval_map
  102. ``
  103. This relation is needed to resolve the instantiation of
  104. infix operators e.g. `T operator + (P, Q)` for two interval container types
  105. `P` and `Q`. If both `P` and `Q` are candidates for the result
  106. type `T`, one of them must be chosen by the compiler.
  107. We choose the type that is segmentational finer as
  108. result type `T`. This way we do not loose the ['*segment information*]
  109. that is stored in the ['*finer*] one of the container types `P` and `Q`.
  110. ``
  111. // overload tables for
  112. T operator + (T, const P&)
  113. T operator + (const P&, T)
  114. element containers: interval containers:
  115. + | e b s m + | e i b p S1 S2 S3 M1 M3
  116. ---+-------- ---+---------------------------
  117. e | s e | S1 S2 S3
  118. b | m i | S1 S2 S3
  119. s | s s b | M1 M3
  120. m | m m p | M1 M3
  121. S1 | S1 S1 S1 S2 S3
  122. S2 | S2 S2 S2 S2 S3
  123. S3 | S3 S3 S3 S3 S3
  124. M1 | M1 M1 M1 M3
  125. M3 | M3 M3 M3 M3
  126. ``
  127. So looking up a type combination for e.g.
  128. `T operator + (interval_map, split_interval_map)`
  129. which is equivalent to
  130. `T operator + (M1, M3)`
  131. we find for row type `M1` and column type `M3`
  132. that `M3`
  133. will be assigned as result type, because `M3`
  134. is finer than `M1`.
  135. So this type combination will result in
  136. choosing this
  137. ``
  138. split_interval_map operator + (const interval_map&, split_interval_map)
  139. ``
  140. implementation by the compiler.
  141. [endsect][/ Segmentational Fineness]
  142. [section Key Types]
  143. In an *stl* map `map<K,D>` the first parameter type of the map
  144. template `K` is called `key_type`. It allows to select key-value pairs
  145. pairs via `find(const K&)`
  146. and to remove key-value pairs using `erase(const K&)`.
  147. For icl Maps we have generalized key types to a larger
  148. set of types. Not only the `key_type` (`domain_type`)
  149. but also an interval type and a set type can be ['*key types*],
  150. that allow for ['*selection*] and ['*removal*] of map elements
  151. segments and submaps.
  152. [table Selection of elements, segments and sub maps using key types
  153. [[ ][ __M: __itv_maps__ ][ __m: icl_map ]]
  154. [[__e: `domain_type` ][ key value pair ][ key value pair ]]
  155. [[__i: `interval_type` ][ interval value pair ][ ]]
  156. [[__S: __itv_sets__ ][ interval map ][ ]]
  157. [[__s: __icl_set__ ][ ][ interval map ]]
  158. ]
  159. __biLSubtraction__, __biLerasure__, __biLintersection__
  160. [/ , which is a generalized find ]
  161. and __biLcontainedness__ predicates
  162. can be used with those kinds of key types.
  163. For instance, the overload table for intersection
  164. ``
  165. // overload tables for
  166. T& operator &= (T&, const P&)
  167. element containers: interval containers:
  168. &= | e b s m &= | e i b p S M
  169. ---+-------- ---+------------
  170. s | s s S | S S S
  171. m | m m m m M | M M M M M M
  172. ``
  173. has a part that that allows for selection by key objects
  174. ``
  175. element containers: interval containers:
  176. &= | e b s m &= | e i b p S M
  177. ---+-------- ---+------------
  178. s | s s S | S S S
  179. m | m m M | M M M
  180. ``
  181. and another part that provides overloads for
  182. generalized intersection:
  183. ``
  184. element containers: interval containers:
  185. &= | e b s m &= | e i b p S M
  186. ---+-------- ---+------------
  187. s | s s S | S S S
  188. m | m m M | M M M
  189. ``
  190. For `Sets`, the ['*key types*] defined for maps
  191. are identical with the set types themselves.
  192. So the distinction between the function groups
  193. ['*selection by key*] and ['*generalized intersection*]
  194. fall together in the well known ['*set intersection*].
  195. [endsect][/ Key Types]
  196. [include functions_cons_copy_dest.qbk]
  197. [include functions_containedness.qbk]
  198. [include functions_equivs_orderings.qbk]
  199. [include functions_size.qbk]
  200. [include functions_range.qbk]
  201. [include functions_selection.qbk]
  202. [include functions_addition.qbk]
  203. [include functions_subtraction.qbk]
  204. [include functions_insertion.qbk]
  205. [include functions_erasure.qbk]
  206. [include functions_intersection.qbk]
  207. [include functions_symmetric_difference.qbk]
  208. [include functions_iterator_related.qbk]
  209. [include functions_element_iteration.qbk]
  210. [include functions_streaming.qbk]
  211. [include functions_interval_construct.qbk]
  212. [include functions_interval_orderings.qbk]
  213. [include functions_interval_misc.qbk]
  214. [endsect][/ Function Reference]