functions_erasure.qbk 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. [/ //= Erasure ===================================================================]
  8. [section Erasure]
  9. [section Synopsis][/ Erasure]
  10. [table
  11. [[['*Erasure*]] [__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__] ]
  12. [[`T& T::erase(const P&)`] [__ei ] [__ei __bp] [__e] [__bp] ]
  13. [[`T& erase(T&, const P&)`] [__eiS] [__eiS __bpM] [__es] [__bm] ]
  14. [[`void T::erase(iterator)`] [1] [1] [1] [1] ]
  15. [[`void T::erase(iterator,iterator)`] [1] [1] [1] [1] ]
  16. ]
  17. [h5 Erasure]
  18. The effects of ['*erasure*] implemented by `erase` and ['*subtraction*]
  19. implemented by `subtract` and `operator -=` are identical for all Set-types of
  20. the *icl*.
  21. For Map-types, `erase` provides the *stl* semantics of erasure in
  22. contrast to `subtract` and `operator -=`, that implement a generalized subtraction,
  23. that performs inverse aggregations if key values collide or key intervals overlap.
  24. Using iterators it is possible to erase objects or ranges of
  25. objects the iterator is pointing at from icl Sets and Maps.
  26. [endsect][/ Synopsis Erasure]
  27. [section Erasure of Objects]
  28. ``
  29. /* overload table for */ T\P| e i b p
  30. T& T::erase(const P&) ---+--------
  31. T& erase(T&, const P&) s | s
  32. m | m
  33. S | S S
  34. M | M M
  35. ``
  36. The next table contains complexity characteristics for the `erase` function on elements and segments.
  37. [table Time Complexity for erasure of elements and segments on icl containers
  38. [[`T& T::erase(const P&)`\n
  39. `T& erase(T&, const P&)`] [__ch_dom_t__][__ch_itv_t__][__ch_dom_mp_t__][__ch_itv_mp_t__]]
  40. [[__icl_set__] [__Olgn__] [] [] [] ]
  41. [[__icl_map__] [__Olgn__] [] [__Olgn__] [] ]
  42. [[__itv_sets__] [__Olgn__] [__a_Olgn__] [] [] ]
  43. [[__itv_maps__] [__Olgn__] [__On__] [__Olgn__] [__On__] ]
  44. ]
  45. As presented in the overload tables for inplace function `erase` below,
  46. more type combinations are available for /erasure/ than for
  47. /insertion/.
  48. ``
  49. // overload tables for function element containers: interval containers:
  50. T& erase(T&, const P&) T\P| e b s m T\P| e i b p S M
  51. ---+-------- ---+------------
  52. s | s s S | S S S
  53. m | m m m m M | M M M M M M
  54. ``
  55. We can split up these overloads in two groups.
  56. The first group can be called /reverse insertion/.
  57. ``
  58. /* (1) Reverse insertion */ T\P| e b s m T\P| e i b p S M
  59. ---+-------- ---+------------
  60. s | s s S | S S S
  61. m | m m M | M M M
  62. ``
  63. The second group can be viewed as an /erasure by key objects/
  64. ``
  65. /* (2) Erasure by key objects */ T\P| e b s m T\P| e i b p S M
  66. ---+-------- ---+------------
  67. s | s s S | S S S
  68. m | m m M | M M M
  69. ``
  70. On Maps ['*reverse insertion (1)*] is different from
  71. *stl's* erase semantics, because value pairs are deleted only,
  72. if key ['*and*] data values are found. Only
  73. ['*erasure by key objects (2)*] works like the erase function
  74. on *stl's* std::maps, that passes a ['*key value*] as argument.
  75. On Sets both function groups fall together
  76. as ['*set difference*].
  77. Complexity characteristics for inplace erasure operations are
  78. given by the next tables where
  79. ``
  80. n = iterative_size(y);
  81. m = iterative_size(x); //if P is a container type
  82. ``
  83. [table Time Complexity for inplace erasure on element containers
  84. [[`T& erase(T& y, const P& x)`][__ch_dom_t__][__ch_dom_mp_t__][__ch_icl_set__][__ch_icl_map__]]
  85. [[__icl_set__] [__Olgn__] [] [__Omlgn__] [] ]
  86. [[__icl_map__] [__Olgn__] [__Olgn__] [__Omlgn__] [__Omlgn__] ]
  87. ]
  88. [table Time Complexity for inplace erasure on interval containers
  89. [[`T& erase(T& y, const P& x)`][__ch_dom_t__][__ch_itv_t__][__ch_dom_mp_t__][__ch_itv_mp_t__][__ch_itv_sets__][__ch_itv_maps__]]
  90. [[interval_sets] [__Olgn__] [__a_Olgn__] [] [] [__Omlgnpm__] [] ]
  91. [[interval_maps] [__Olgn__] [__a_Olgn__] [__Olgn__] [__On__] [__Omlgnpm__] [__Omlgnpm__] ]
  92. ]
  93. [endsect][/ Erasure of Objects]
  94. [section Erasure by Iterators]
  95. The next table shows the *icl* containers that erasure with iterators is
  96. available for. Erase on iterators erases always one `value` of `value_type`
  97. for an iterator pointing to it.
  98. So we erase
  99. * elements from __icl_sets__
  100. * element-value pairs from __icl_maps__
  101. * intervals from __itv_sets__ and
  102. * interval-value-pairs from __itv_maps__
  103. [table
  104. [[['*Erasure by iterators*]] [__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__] ]
  105. [[`void T::erase(iterator pos)`] [__aO1__] [__aO1__] [__aO1__] [__aO1__] ]
  106. [[`void T::erase(iterator first, iterator past)`] [__Ok__] [__Ok__] [__Ok__] [__Ok__] ]
  107. ]
  108. Erasing by a single iterator need only ['*amortized constant time*].
  109. Erasing via a range of iterators `[first, past)` is of ['*linear time*]
  110. in the number `k` of iterators in range `[first, past)`.
  111. [endsect][/ Erasure by Iterators]
  112. ['*See also . . .*]
  113. [table
  114. []
  115. [[[link boost_icl.function_reference.insertion ['*Insertion*]] ]]
  116. [[[link boost_icl.function_reference.subtraction ['*Subtraction*]] ]]
  117. ]
  118. ['*Back to section . . .*]
  119. [table
  120. []
  121. [[[link function_synopsis_table ['*Function Synopsis*]] ]]
  122. [[[link boost_icl.interface ['*Interface*]] ]]
  123. ]
  124. [endsect][/ Erasure]