functions_subtraction.qbk 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. [/ //= Subtraction ============================================================]
  8. [section Subtraction]
  9. [section Synopsis]
  10. [table
  11. [[Subtraction] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  12. [[`T& T::subtract(const P&)`] [ ] [__ei] [__bp] [ ] [__b] ]
  13. [[`T& subtract(T&, const P&)`] [ ] [__ei] [__bp] [__e] [__b] ]
  14. [[`T& operator -=(T&, const P&)`] [ ] [__eiS][__eiS __bpM][__es] [__bm] ]
  15. [[`T operator - (T, const P&)`] [ ] [__eiS][__eiS __bpM][__es] [__bm] ]
  16. [[`T left_subtract(T, const T&)`] [1] [ ] [ ] [ ] [ ] ]
  17. [[`T right_subtract(T, const T&)`] [1] [ ] [ ] [ ] [ ] ]
  18. ]
  19. Functions and operators that implement ['*Subtraction*] on *icl* objects
  20. are given in the table above.
  21. [table
  22. [[] [Description of Subtraction]]
  23. [[`Sets`][Subtraction on Sets implements ['*set difference*]]]
  24. [[`Maps`][Subtraction on Maps implements a ['*map difference*] function similar to /set difference/.
  25. If, on subtraction of an element value pair `(k,v)` it's key `k` is in the map
  26. already, the subtraction function is propagated to the associated value.
  27. On the associated value an aggregation is performed, that reverses
  28. the effect of the corresponding addition function.
  29. Find more on
  30. [link boost_icl.concepts.aggrovering ['subtractability of maps]]
  31. and related
  32. [link boost_icl.semantics.maps ['semantic issues]]
  33. following the links.
  34. ]]
  35. ]
  36. [endsect][/ Synopsis]
  37. [section Functions][/ Subtraction]
  38. The admissible combinations of types for subtraction functions
  39. can be summarized in the
  40. ['*overload table*] below:
  41. ``
  42. // overload table for T\P| e i b p
  43. T& T::subtract(const P&) ---+--------
  44. T& subtract(T&, const P&) s | s
  45. m | m
  46. S | S S
  47. M | M M
  48. ``
  49. The next table contains complexity characteristics for `subtract`.
  50. [table Time Complexity for function subtract on icl containers
  51. [[`T& T::subtract(const P&)`\n
  52. `T& subtract(T&, const P&)`] [__ch_dom_t__][__ch_itv_t__][__ch_dom_mp_t__][__ch_itv_mp_t__]]
  53. [[__icl_set__] [__Olgn__] [] [] [] ]
  54. [[__icl_map__] [__Olgn__] [] [__Olgn__] [] ]
  55. [[__itv_sets__] [__Olgn__] [__a_Olgn__] [] [] ]
  56. [[__itv_maps__] [__Olgn__] [__On__] [__Olgn__] [__On__] ]
  57. ]
  58. [endsect][/ Member function Subtraction]
  59. [section Inplace operators][/ Subtraction]
  60. As presented in the overload tables for `operator -=`
  61. more type combinations are provided for subtraction than for
  62. addition.
  63. ``
  64. // overload tables for element containers: interval containers:
  65. T& operator -= (T&, const P&) -= | e b s m -= | e i b p S M
  66. ---+-------- ---+------------
  67. s | s s S | S S S
  68. m | m m m m M | M M M M M M
  69. ``
  70. Subtraction provides the /reverse/ operation
  71. of an addition for these overloads,
  72. ``
  73. // Reverse addition -= | e b s m -= | e i b p S M
  74. ---+-------- ---+------------
  75. s | s s S | S S S
  76. m | m m M | M M M
  77. ``
  78. [*and] you can erase parts of __icl_maps__ or __itv_maps__
  79. using
  80. /key values/, /intervals/ or /element or interval sets/
  81. using these overloads:
  82. ``
  83. // Erasure by key objects -= | e b s m -= | e i b p S M
  84. ---+-------- ---+------------
  85. s | s s S | S S S
  86. m | m m M | M M M
  87. ``
  88. On Sets both function groups fall together
  89. as ['*set difference*].
  90. Complexity characteristics for inplace subtraction operations are
  91. given by the next tables where
  92. ``
  93. n = iterative_size(y);
  94. m = iterative_size(x); //if P is a container type
  95. ``
  96. [table Time Complexity for inplace Subtraction on element containers
  97. [[`T& operator -= (T&, const P&)`][__ch_dom_t__][__ch_dom_mp_t__][__ch_icl_set__][__ch_icl_map__]]
  98. [[__icl_set__] [__Olgn__] [] [__Omlgn__] [] ]
  99. [[__icl_map__] [__Olgn__] [__Olgn__] [__Omlgn__] [__Omlgn__] ]
  100. ]
  101. [table Time Complexity for inplace Subtraction on interval containers
  102. [[`T& operator -= (T&, const P&)`][__ch_dom_t__][__ch_itv_t__][__ch_dom_mp_t__][__ch_itv_mp_t__][__ch_itv_sets__][__ch_itv_maps__]]
  103. [[interval_sets] [__Olgn__] [__a_Olgn__] [] [] [__Omlgnpm__] [] ]
  104. [[interval_maps] [__Olgn__] [__a_Olgn__] [__Olgn__] [__On__] [__Omlgnpm__] [__Omlgnpm__] ]
  105. ]
  106. [endsect][/ Inplace operators Subtraction]
  107. [section Infix operators][/-Subtraction]
  108. The admissible overloads for the infix
  109. /subtraction/ `operator -`
  110. which is a non commutative
  111. operation
  112. is given by the next overload table.
  113. ``
  114. // overload tables for - | e b s m - | e i b p S M
  115. T operator - (T, const P&) ---+-------- ---+------------
  116. s | s s S | S S S
  117. m | m m m m M | M M M M M M
  118. ``
  119. [endsect][/- Infix operator Subtraction]
  120. [section Subtraction on Intervals]
  121. [table
  122. [[['*Subtraction*]] [Types] [Description] ]
  123. [[`T left_subtract(T right, const T& left_minuend)`] [__i]
  124. [subtract `left_minuend` from the interval `right` on it's left side.
  125. ``
  126. right_over = left_subtract(right, left_minuend);
  127. ... d) : right
  128. ... c) : left_minuend
  129. [c d) : right_over
  130. ``
  131. ] ]
  132. [[`T right_subtract(T left, const T& right_minuend)`] [__i]
  133. [subtract `right_minuend` from the interval `left` on it's right side.
  134. ``
  135. left_over = right_subtract(left, right_minuend);
  136. [a ... : left
  137. [b ... : right_minuend
  138. [a b) : left_over
  139. ``
  140. ] ]
  141. ]
  142. [endsect][/ Subtraction on Intervals]
  143. ['*See also . . .*]
  144. [table
  145. []
  146. [[[link boost_icl.function_reference.addition ['*Addition*]] ]]
  147. [[[link boost_icl.function_reference.erasure ['*Erasure*]] ]]
  148. ]
  149. ['*Back to section . . .*]
  150. [table
  151. []
  152. [[[link function_synopsis_table ['*Function Synopsis*]] ]]
  153. [[[link boost_icl.interface ['*Interface*]] ]]
  154. ]
  155. [endsect][/ Subtraction]