functions_equivs_orderings.qbk 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. [/ //= Equivalences and Orderings ===================================================]
  8. [section Equivalences and Orderings]
  9. [section Synopsis][/ Equivalences and Orderings]
  10. [table
  11. [[['*Equivalences and Orderings*]][__ch_itvs__][__ch_itv_sets__][__ch_itv_maps__][__ch_ele_sets__][__ch_ele_maps__]]
  12. [[['Segment Ordering]] [ ] [ ] [ ] [ ] [ ] ]
  13. [[`bool operator == (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  14. [[`bool operator != (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  15. [[`bool operator < (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  16. [[`bool operator > (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  17. [[`bool operator <= (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  18. [[`bool operator >= (const T&, const T&)`] [1] [1] [1] [1] [1] ]
  19. [[['Element Ordering]] [ ] [ ] [ ] [ ] [ ] ]
  20. [[`bool is_element_equal(const T&, const P&)`] [ ] [__S] [__M] [1] [1] ]
  21. [[`bool is_element_less(const T&, const P&)`] [ ] [__S] [__M] [1] [1] ]
  22. [[`bool is_element_greater(const T&, const P&)`][ ] [__S] [__M] [1] [1] ]
  23. [[['Distinct Equality]] [ ] [ ] [ ] [ ] [ ] ]
  24. [[`bool is_distinct_equal(const T&, const P&)`][ ] [ ] [__M] [ ] [1] ]
  25. ]
  26. [endsect][/ Synopsis Equivalences and Orderings]
  27. [section Less on Intervals]
  28. [table
  29. [[ ] [Types][]]
  30. [[`x < y`] [__i] [`x` begins before `y` or, for equal beginnings `x` ends before `y`]]
  31. ]
  32. [endsect][/ Less on Intervals]
  33. [section Lexicographical Ordering][/ Equivalences and Orderings]
  34. All common equality and compare operators are defined for
  35. all objects of the *icl*. For all *icl* containers
  36. equality and compare operators implement lexicographical
  37. equality and lexicographical comparison, that depends on
  38. the equality of template parameter `Compare`.
  39. This includes the less ordering on intervals, that can be
  40. perceived as the sequence of elements between their lower and upper
  41. bound. This generalized lexicogrphical comparison in intervals
  42. can also be specified this way:
  43. [table
  44. []
  45. [[`x < y`] [`:=`] [`x` begins before `y` or, for equal beginnings `x` ends before `y`.]]
  46. [[] [] [The other operators can be deduced in the usual way]]
  47. [[`x > y`] [`:=`] [`y < x`] ]
  48. [[`x <= y`] [`:=`] [`!(y < x)`] ]
  49. [[`x >= y`] [`:=`] [`!(x < y)`] ]
  50. [[`x == y`] [`:=`] [`!(x < y) && !(y < x)` induced equivalence] ]
  51. [[`x != y`] [`:=`] [`!(x == y)`] ]
  52. ]
  53. Equality and compare operators are defined for all *icl*
  54. objects but there are no overloads between different types.
  55. Containers of different segmentation are different,
  56. even if their elements are the same:
  57. ``
  58. split_interval_set<time> w1, w2; //Pseudocode
  59. w1 = {[Mon .. Sun)}; //split_interval_set containing a week
  60. w2 = {[Mon .. Fri)[Sat .. Sun)}; //Same week split in work and week end parts.
  61. w1 == w2; //false: Different segmentation
  62. is_element_equal(w1,w2); //true: Same elements contained
  63. ``
  64. [*Complexity] is ['*linear*] in the `iterative_size` of the shorter
  65. container to compare.
  66. [endsect][/ Lexicographical Ordering; Equivalences and Orderings]
  67. [/ ----------------------------------------------------------------------------]
  68. [section Sequential Element Ordering][/ Equivalences and Orderings]
  69. The ['*Sequential Element Ordering*] abstracts from the way in which
  70. elements of interval containers are clustered into intervals:
  71. it's ['*segmentation*].
  72. So these equality and compare operations can be applied within
  73. interval container types. The admissible type combinations are summarized
  74. in the next overload table.
  75. ``
  76. // overload tables for
  77. bool is_element_equal (const T&, const P&)
  78. bool is_element_less (const T&, const P&)
  79. bool is_element_greater(const T&, const P&)
  80. element containers: interval containers:
  81. T\P| s m T\P| S1 S2 S3 M1 M3
  82. ---+---- ---+---------------
  83. s | 1 S1 | 1 1 1
  84. m | 1 S2 | 1 1 1
  85. S3 | 1 1 1
  86. M1 | 1 1
  87. M3 | 1 1
  88. ``
  89. For element containers lexicographical equality and
  90. sequential element equality are identical.
  91. The *complexity* of sequential element comparison functions
  92. is ['*linear*] in the `iterative_size` of the larger
  93. container.
  94. [endsect]
  95. [section Distinct Equality]
  96. ['*Distinct Equality*] is an equality predicate that is available
  97. for __icl_maps__ and __itv_maps__. It yields true, if
  98. two maps are sequential element equal except for value
  99. pairs whose associated values are identity elements.
  100. [*Complexity] is linear in the `iterative_size` of the
  101. larger container to compare.
  102. [endsect]
  103. ['*See also . . .*]
  104. [table
  105. []
  106. [[[link boost_icl.semantics.orderings_and_equivalences ['*Semantics*]]]]
  107. ]
  108. ['*Back to section . . .*]
  109. [table
  110. []
  111. [[[link function_synopsis_table ['*Function Synopsis*]]]]
  112. [[[link boost_icl.interface ['*Interface*]] ]]
  113. ]
  114. [endsect][/ Equivalences and Orderings]