functions_containedness.qbk 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. [/ //= Containedness ===================================================================]
  8. [section Containedness]
  9. [table
  10. [[['*Containedness*]] [__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__] ]
  11. [[`bool T::empty()const`] [ ] [1] [1] [1] [1] ]
  12. [[`bool is_empty(const T&)`] [1] [1] [1] [1] [1] ]
  13. [[`bool contains(const T&, const P&)`\n
  14. `bool within(const P&, const T&)`] [__ei] [__eiS][__eiS __bpM][__es] [__bm] ]
  15. ]
  16. This group of functions refers to ['*contain*]edness which should
  17. be fundamental to ['*contain*]ers. The function `contains`
  18. is overloaded. It covers different kinds of containedness:
  19. Containedness of elements, segments, and sub containers.
  20. [table
  21. [[['*Containedness*]] [ /O(...)/ ][Description ] ]
  22. [[`bool T::empty()const`\n
  23. `bool is_empty(const T&)`] [__O1__][Returns `true`, if the container is empty, `false` otherwise.] ]
  24. [[`bool contains(const T&, const P&)`\n
  25. `bool within(const P&, const T&)`] [[link complexities_contains ['see below]]]
  26. [Returns `true`, if `super` container contains object `sub`.] ]
  27. [[ ] [where] [ /n/` = iterative_size(sub)`] ]
  28. [[ ] [ ] [ /m/` = iterative_size(super)`] ]
  29. ]
  30. ``
  31. // overload tables for
  32. bool contains(const T& super, const P& sub)
  33. bool within(const P& sub, const T& super)
  34. element containers: interval containers:
  35. T\P| e b s m T\P| e i b p S M
  36. --------+--- --------+-------
  37. s | 1 1 S | 1 1 1
  38. m | 1 1 1 1 M | 1 1 1 1 1 1
  39. ``
  40. The overloads of `bool contains(const T& super, const P& sup)`
  41. cover various kinds
  42. of containedness. We can group them into a part (1) that checks
  43. if an element, a segment or a container /of same kinds/ is contained in
  44. an element or interval container
  45. ``
  46. // (1) containedness of elements, segments or containers of same kind
  47. T\P| e b s m T\P| e i b p S M
  48. ---+-------- ---+------------
  49. s | 1 1 S | 1 1 1
  50. m | 1 1 M | 1 1 1
  51. ``
  52. and another part (2) that checks the containedness of
  53. /key objects/, which can be /elements/ an /intervals/ or a /sets/.
  54. ``
  55. // (2) containedness of key objects.
  56. T\P| e b s m T\P| e i b p S M
  57. ---+-------- ---+------------
  58. s | 1 1 S | 1 1 1
  59. m | 1 1 M | 1 1 1
  60. ``
  61. For type *m* = __icl_map__,
  62. a key element (*m*`::domain_type`) and an __icl_set__
  63. (*m*`::set_type`) can be a ['*key object*].
  64. For an interval map type *M*,
  65. a key element (*M*`::domain_type`),
  66. an interval (*M*`::interval_type`) and an
  67. ['*interval set*], can be ['*key objects*].
  68. [#complexities_contains] Complexity characteristics for function
  69. `bool contains(const T& super, const P& sub)const`
  70. are given by the next tables where
  71. ``
  72. n = iterative_size(super);
  73. m = iterative_size(sub); //if P is a container type
  74. ``
  75. [table Time Complexity for function contains on element containers
  76. [[`bool contains(const T& super, const P& sub)`\n
  77. `bool within(const P& sub, const T& super)`][__ch_dom_t__][__ch_dom_mp_t__][__ch_icl_set__][__ch_icl_map__]]
  78. [[__icl_set__] [__Olgn__] [] [__Omlgn__] [] ]
  79. [[__icl_map__] [__Olgn__] [__Olgn__] [__Omlgn__] [__Omlgn__] ]
  80. ]
  81. [table Time Complexity for functions contains and within on interval containers
  82. [[`bool contains(const T& super, const P& sub)`\n
  83. `bool within(const P& sub, const T& super)`][][__ch_dom_t__][__ch_itv_t__][__ch_dom_mp_t__][__ch_itv_mp_t__][__ch_itv_sets__][__ch_itv_maps__]]
  84. [[interval_sets] [__itv_set__][__Olgn__] [__Olgn__] [] [] [__Omlgn__] [] ]
  85. [[] [__sep_itv_set__\n__spl_itv_set__][__Olgn__] [__On__ ] [] [] [__Omlgn__] [] ]
  86. [[interval_maps] [__itv_map__][__Olgn__] [__Olgn__] [__Olgn__] [__Olgn__] [__Omlgn__] [__Omlgn__] ]
  87. [[] [__spl_itv_map__][__Olgn__] [__On__ ] [__Olgn__] [__On__] [__Omlgn__] [__Omlgn__] ]
  88. ]
  89. All overloads of containedness of containers in containers
  90. ``
  91. bool contains(const T& super, const P& sub)
  92. bool within(const P& sub, const T& super)
  93. ``
  94. are of ['*loglinear*] time: __Omlgn__.
  95. If both containers have same iterative_sizes so that /m = n/
  96. we have the worst case ( __Onlgn__ ).
  97. There is an alternative implementation that has a ['*linear*]
  98. complexity of __Onpm__.
  99. The loglinear implementation has been chosen,
  100. because it can be faster, if the container argument is
  101. small. In this case the loglinear implementation approaches
  102. logarithmic behavior, whereas the linear implementation
  103. stays linear.
  104. ['*Back to section . . .*]
  105. [table
  106. []
  107. [[[link function_synopsis_table ['*Function Synopsis*]]]]
  108. [[[link boost_icl.interface ['*Interface*]] ]]
  109. ]
  110. [endsect][/ Containedness]