You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
7.1 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: stlsoft/algorithms/deprecated.hpp
  3. *
  4. * Purpose: Deprecated algorithms.
  5. *
  6. * Created: 17th January 2002
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////////// */
  39. /** \file stlsoft/algorithms/deprecated.hpp
  40. *
  41. * \brief [C++ only] Deprecated algorithms
  42. * (\ref group__library__algorithms "Algorithms" Library).
  43. */
  44. #ifndef STLSOFT_INCL_STLSOFT_ALGORITHMS_HPP_DEPRECATED
  45. #define STLSOFT_INCL_STLSOFT_ALGORITHMS_HPP_DEPRECATED
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define STLSOFT_VER_STLSOFT_ALGORITHMS_HPP_DEPRECATED_MAJOR 3
  48. # define STLSOFT_VER_STLSOFT_ALGORITHMS_HPP_DEPRECATED_MINOR 0
  49. # define STLSOFT_VER_STLSOFT_ALGORITHMS_HPP_DEPRECATED_REVISION 4
  50. # define STLSOFT_VER_STLSOFT_ALGORITHMS_HPP_DEPRECATED_EDIT 69
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Includes
  54. */
  55. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  56. # include <stlsoft/stlsoft.h>
  57. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  58. #ifndef STLSOFT_INCL_STLSOFT_ALGORITHMS_HPP_UNORDERED
  59. # include <stlsoft/algorithms/unordered.hpp>
  60. #endif /* !STLSOFT_INCL_STLSOFT_ALGORITHMS_HPP_UNORDERED */
  61. #ifndef STLSOFT_INCL_STLSOFT_ALGORITHMS_STD_HPP_EXT
  62. # include <stlsoft/algorithms/std/ext.hpp>
  63. #endif /* !STLSOFT_INCL_STLSOFT_ALGORITHMS_STD_HPP_EXT */
  64. #ifndef STLSOFT_INCL_STLSOFT_ALGORITHMS_STD_HPP_ALT
  65. # include <stlsoft/algorithms/std/alt.hpp>
  66. #endif /* !STLSOFT_INCL_STLSOFT_ALGORITHMS_STD_HPP_ALT */
  67. /* /////////////////////////////////////////////////////////////////////////
  68. * Namespace
  69. */
  70. #ifndef _STLSOFT_NO_NAMESPACE
  71. namespace stlsoft
  72. {
  73. #endif /* _STLSOFT_NO_NAMESPACE */
  74. /* /////////////////////////////////////////////////////////////////////////
  75. * Algorithms
  76. */
  77. /** \brief Counts the number of items in the sequence which the predicate is true.
  78. *
  79. * \ingroup group__library__algorithms
  80. *
  81. * \note This function is identical in semantics to std::count_if(). If you are
  82. * compiling in the context of a standard compliant library, you should prefer
  83. * std::count_if().
  84. *
  85. * \param first The start of the range to count
  86. * \param last The end of the range to count
  87. * \param pred The predicate
  88. */
  89. template< ss_typename_param_k I
  90. , ss_typename_param_k P
  91. >
  92. // [[synesis:function:algorithm: for_each_count_success(T<I> first, T<I> last, T<UP> pred)]]
  93. inline ss_size_t for_each_count_success(I first, I last, P pred)
  94. {
  95. return std_count_if(first, last, pred);
  96. }
  97. /** \brief Sets the value of all items in the sequence.
  98. *
  99. * \ingroup group__library__algorithms
  100. *
  101. * \note This function is identical in semantics to std::fill(), except that
  102. * it returns the value. If you are compiling in the context of a standard
  103. * compliant library, and do not need the value returned, you should prefer
  104. * std::fill().
  105. *
  106. * \param begin The start of the sequence
  107. * \param end The end of the sequence
  108. * \param value The value to be applied to item N, for each N in [begin, end)
  109. */
  110. template< ss_typename_param_k I
  111. , ss_typename_param_k V
  112. >
  113. // [[synesis:function:algorithm: for_each_set_value(T<I> first, T<I> last, T<V> value)]]
  114. inline V const& for_each_set_value(I begin, I end, V const& value)
  115. {
  116. std_fill(begin, end);
  117. return value;
  118. }
  119. /** \brief Sets the value of all items in the sequence.
  120. *
  121. * \ingroup group__library__algorithms
  122. *
  123. * \deprecated This is the old name for fill_if().
  124. *
  125. * \param begin The start of the sequence
  126. * \param end The end of the sequence
  127. * \param value The value to be applied to item N, for each N in [begin, end), when <code>pred(*(begin + N))</code> evaluates non-zero
  128. * \param pred The predicate that determines whether the value is to be modified
  129. */
  130. // [[synesis:function:algorithm: for_each_set_value_if(T<I> first, T<I> last, T<V> value, T<UP> pred)]]
  131. template< ss_typename_param_k O
  132. , ss_typename_param_k V
  133. , ss_typename_param_k P
  134. >
  135. inline V const& for_each_set_value_if(O begin, O end, V const& value, P pred)
  136. {
  137. fill_if(begin, end, value, pred);
  138. return value;
  139. }
  140. #if 0
  141. /** \brief This algorithm removes duplicate entries from unordered sequences. It
  142. * necessarily runs in O(n) time, since it must do a bubble-like double
  143. * pass on the sequence (in order to work with unordered sequences).
  144. *
  145. * \ingroup group__library__algorithms
  146. *
  147. * \deprecated This is the old name for unordered_unique().
  148. *
  149. * \param container The container
  150. * \param pred The predicate
  151. */
  152. template< ss_typename_param_k C
  153. , ss_typename_param_k P
  154. >
  155. // [[synesis:function:algorithm: remove_duplicates_from_unordered_sequence(T<C> container, T<UP> pred)]]
  156. inline void remove_duplicates_from_unordered_sequence(C &container, P pred)
  157. {
  158. // unordered_unique(container.begin(), container.end()
  159. static_assert(0);
  160. }
  161. #endif /* 0 */
  162. ////////////////////////////////////////////////////////////////////////////
  163. // Unit-testing
  164. #ifdef STLSOFT_UNITTEST
  165. # include "./unittest/deprecated_unittest_.h"
  166. #endif /* STLSOFT_UNITTEST */
  167. /* ////////////////////////////////////////////////////////////////////// */
  168. #ifndef _STLSOFT_NO_NAMESPACE
  169. } // namespace stlsoft
  170. #endif /* _STLSOFT_NO_NAMESPACE */
  171. /* ////////////////////////////////////////////////////////////////////// */
  172. #endif /* !STLSOFT_INCL_STLSOFT_ALGORITHMS_HPP_DEPRECATED */
  173. /* ///////////////////////////// end of file //////////////////////////// */