| 1 | // <algorithm> Forward declarations  -*- C++ -*- | 
|---|
| 2 |  | 
|---|
| 3 | // Copyright (C) 2007-2018 Free Software Foundation, Inc. | 
|---|
| 4 | // | 
|---|
| 5 | // This file is part of the GNU ISO C++ Library.  This library is free | 
|---|
| 6 | // software; you can redistribute it and/or modify it under the | 
|---|
| 7 | // terms of the GNU General Public License as published by the | 
|---|
| 8 | // Free Software Foundation; either version 3, or (at your option) | 
|---|
| 9 | // any later version. | 
|---|
| 10 |  | 
|---|
| 11 | // This library is distributed in the hope that it will be useful, | 
|---|
| 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 14 | // GNU General Public License for more details. | 
|---|
| 15 |  | 
|---|
| 16 | // Under Section 7 of GPL version 3, you are granted additional | 
|---|
| 17 | // permissions described in the GCC Runtime Library Exception, version | 
|---|
| 18 | // 3.1, as published by the Free Software Foundation. | 
|---|
| 19 |  | 
|---|
| 20 | // You should have received a copy of the GNU General Public License and | 
|---|
| 21 | // a copy of the GCC Runtime Library Exception along with this program; | 
|---|
| 22 | // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see | 
|---|
| 23 | // <http://www.gnu.org/licenses/>. | 
|---|
| 24 |  | 
|---|
| 25 | /** @file bits/algorithmfwd.h | 
|---|
| 26 | *  This is an internal header file, included by other library headers. | 
|---|
| 27 | *  Do not attempt to use it directly. @headername{algorithm} | 
|---|
| 28 | */ | 
|---|
| 29 |  | 
|---|
| 30 | #ifndef _GLIBCXX_ALGORITHMFWD_H | 
|---|
| 31 | #define _GLIBCXX_ALGORITHMFWD_H 1 | 
|---|
| 32 |  | 
|---|
| 33 | #pragma GCC system_header | 
|---|
| 34 |  | 
|---|
| 35 | #include <bits/c++config.h> | 
|---|
| 36 | #include <bits/stl_pair.h> | 
|---|
| 37 | #include <bits/stl_iterator_base_types.h> | 
|---|
| 38 | #if __cplusplus >= 201103L | 
|---|
| 39 | #include <initializer_list> | 
|---|
| 40 | #endif | 
|---|
| 41 |  | 
|---|
| 42 | namespace std _GLIBCXX_VISIBILITY(default) | 
|---|
| 43 | { | 
|---|
| 44 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | 
|---|
| 45 |  | 
|---|
| 46 | /* | 
|---|
| 47 | adjacent_find | 
|---|
| 48 | all_of (C++11) | 
|---|
| 49 | any_of (C++11) | 
|---|
| 50 | binary_search | 
|---|
| 51 | clamp (C++17) | 
|---|
| 52 | copy | 
|---|
| 53 | copy_backward | 
|---|
| 54 | copy_if (C++11) | 
|---|
| 55 | copy_n (C++11) | 
|---|
| 56 | count | 
|---|
| 57 | count_if | 
|---|
| 58 | equal | 
|---|
| 59 | equal_range | 
|---|
| 60 | fill | 
|---|
| 61 | fill_n | 
|---|
| 62 | find | 
|---|
| 63 | find_end | 
|---|
| 64 | find_first_of | 
|---|
| 65 | find_if | 
|---|
| 66 | find_if_not (C++11) | 
|---|
| 67 | for_each | 
|---|
| 68 | generate | 
|---|
| 69 | generate_n | 
|---|
| 70 | includes | 
|---|
| 71 | inplace_merge | 
|---|
| 72 | is_heap (C++11) | 
|---|
| 73 | is_heap_until (C++11) | 
|---|
| 74 | is_partitioned (C++11) | 
|---|
| 75 | is_sorted (C++11) | 
|---|
| 76 | is_sorted_until (C++11) | 
|---|
| 77 | iter_swap | 
|---|
| 78 | lexicographical_compare | 
|---|
| 79 | lower_bound | 
|---|
| 80 | make_heap | 
|---|
| 81 | max | 
|---|
| 82 | max_element | 
|---|
| 83 | merge | 
|---|
| 84 | min | 
|---|
| 85 | min_element | 
|---|
| 86 | minmax (C++11) | 
|---|
| 87 | minmax_element (C++11) | 
|---|
| 88 | mismatch | 
|---|
| 89 | next_permutation | 
|---|
| 90 | none_of (C++11) | 
|---|
| 91 | nth_element | 
|---|
| 92 | partial_sort | 
|---|
| 93 | partial_sort_copy | 
|---|
| 94 | partition | 
|---|
| 95 | partition_copy (C++11) | 
|---|
| 96 | partition_point (C++11) | 
|---|
| 97 | pop_heap | 
|---|
| 98 | prev_permutation | 
|---|
| 99 | push_heap | 
|---|
| 100 | random_shuffle | 
|---|
| 101 | remove | 
|---|
| 102 | remove_copy | 
|---|
| 103 | remove_copy_if | 
|---|
| 104 | remove_if | 
|---|
| 105 | replace | 
|---|
| 106 | replace_copy | 
|---|
| 107 | replace_copy_if | 
|---|
| 108 | replace_if | 
|---|
| 109 | reverse | 
|---|
| 110 | reverse_copy | 
|---|
| 111 | rotate | 
|---|
| 112 | rotate_copy | 
|---|
| 113 | search | 
|---|
| 114 | search_n | 
|---|
| 115 | set_difference | 
|---|
| 116 | set_intersection | 
|---|
| 117 | set_symmetric_difference | 
|---|
| 118 | set_union | 
|---|
| 119 | shuffle (C++11) | 
|---|
| 120 | sort | 
|---|
| 121 | sort_heap | 
|---|
| 122 | stable_partition | 
|---|
| 123 | stable_sort | 
|---|
| 124 | swap | 
|---|
| 125 | swap_ranges | 
|---|
| 126 | transform | 
|---|
| 127 | unique | 
|---|
| 128 | unique_copy | 
|---|
| 129 | upper_bound | 
|---|
| 130 | */ | 
|---|
| 131 |  | 
|---|
| 132 | /** | 
|---|
| 133 | * @defgroup algorithms Algorithms | 
|---|
| 134 | * | 
|---|
| 135 | * Components for performing algorithmic operations. Includes | 
|---|
| 136 | * non-modifying sequence, modifying (mutating) sequence, sorting, | 
|---|
| 137 | * searching, merge, partition, heap, set, minima, maxima, and | 
|---|
| 138 | * permutation operations. | 
|---|
| 139 | */ | 
|---|
| 140 |  | 
|---|
| 141 | /** | 
|---|
| 142 | * @defgroup mutating_algorithms Mutating | 
|---|
| 143 | * @ingroup algorithms | 
|---|
| 144 | */ | 
|---|
| 145 |  | 
|---|
| 146 | /** | 
|---|
| 147 | * @defgroup non_mutating_algorithms Non-Mutating | 
|---|
| 148 | * @ingroup algorithms | 
|---|
| 149 | */ | 
|---|
| 150 |  | 
|---|
| 151 | /** | 
|---|
| 152 | * @defgroup sorting_algorithms Sorting | 
|---|
| 153 | * @ingroup algorithms | 
|---|
| 154 | */ | 
|---|
| 155 |  | 
|---|
| 156 | /** | 
|---|
| 157 | * @defgroup set_algorithms Set Operation | 
|---|
| 158 | * @ingroup sorting_algorithms | 
|---|
| 159 | * | 
|---|
| 160 | * These algorithms are common set operations performed on sequences | 
|---|
| 161 | * that are already sorted. The number of comparisons will be | 
|---|
| 162 | * linear. | 
|---|
| 163 | */ | 
|---|
| 164 |  | 
|---|
| 165 | /** | 
|---|
| 166 | * @defgroup binary_search_algorithms Binary Search | 
|---|
| 167 | * @ingroup sorting_algorithms | 
|---|
| 168 | * | 
|---|
| 169 | * These algorithms are variations of a classic binary search, and | 
|---|
| 170 | * all assume that the sequence being searched is already sorted. | 
|---|
| 171 | * | 
|---|
| 172 | * The number of comparisons will be logarithmic (and as few as | 
|---|
| 173 | * possible).  The number of steps through the sequence will be | 
|---|
| 174 | * logarithmic for random-access iterators (e.g., pointers), and | 
|---|
| 175 | * linear otherwise. | 
|---|
| 176 | * | 
|---|
| 177 | * The LWG has passed Defect Report 270, which notes: <em>The | 
|---|
| 178 | * proposed resolution reinterprets binary search. Instead of | 
|---|
| 179 | * thinking about searching for a value in a sorted range, we view | 
|---|
| 180 | * that as an important special case of a more general algorithm: | 
|---|
| 181 | * searching for the partition point in a partitioned range.  We | 
|---|
| 182 | * also add a guarantee that the old wording did not: we ensure that | 
|---|
| 183 | * the upper bound is no earlier than the lower bound, that the pair | 
|---|
| 184 | * returned by equal_range is a valid range, and that the first part | 
|---|
| 185 | * of that pair is the lower bound.</em> | 
|---|
| 186 | * | 
|---|
| 187 | * The actual effect of the first sentence is that a comparison | 
|---|
| 188 | * functor passed by the user doesn't necessarily need to induce a | 
|---|
| 189 | * strict weak ordering relation.  Rather, it partitions the range. | 
|---|
| 190 | */ | 
|---|
| 191 |  | 
|---|
| 192 | // adjacent_find | 
|---|
| 193 |  | 
|---|
| 194 | #if __cplusplus >= 201103L | 
|---|
| 195 | template<typename _IIter, typename _Predicate> | 
|---|
| 196 | bool | 
|---|
| 197 | all_of(_IIter, _IIter, _Predicate); | 
|---|
| 198 |  | 
|---|
| 199 | template<typename _IIter, typename _Predicate> | 
|---|
| 200 | bool | 
|---|
| 201 | any_of(_IIter, _IIter, _Predicate); | 
|---|
| 202 | #endif | 
|---|
| 203 |  | 
|---|
| 204 | template<typename _FIter, typename _Tp> | 
|---|
| 205 | bool | 
|---|
| 206 | binary_search(_FIter, _FIter, const _Tp&); | 
|---|
| 207 |  | 
|---|
| 208 | template<typename _FIter, typename _Tp, typename _Compare> | 
|---|
| 209 | bool | 
|---|
| 210 | binary_search(_FIter, _FIter, const _Tp&, _Compare); | 
|---|
| 211 |  | 
|---|
| 212 | #if __cplusplus > 201402L | 
|---|
| 213 | template<typename _Tp> | 
|---|
| 214 | _GLIBCXX14_CONSTEXPR | 
|---|
| 215 | const _Tp& | 
|---|
| 216 | clamp(const _Tp&, const _Tp&, const _Tp&); | 
|---|
| 217 |  | 
|---|
| 218 | template<typename _Tp, typename _Compare> | 
|---|
| 219 | _GLIBCXX14_CONSTEXPR | 
|---|
| 220 | const _Tp& | 
|---|
| 221 | clamp(const _Tp&, const _Tp&, const _Tp&, _Compare); | 
|---|
| 222 | #endif | 
|---|
| 223 |  | 
|---|
| 224 | template<typename _IIter, typename _OIter> | 
|---|
| 225 | _OIter | 
|---|
| 226 | copy(_IIter, _IIter, _OIter); | 
|---|
| 227 |  | 
|---|
| 228 | template<typename _BIter1, typename _BIter2> | 
|---|
| 229 | _BIter2 | 
|---|
| 230 | copy_backward(_BIter1, _BIter1, _BIter2); | 
|---|
| 231 |  | 
|---|
| 232 | #if __cplusplus >= 201103L | 
|---|
| 233 | template<typename _IIter, typename _OIter, typename _Predicate> | 
|---|
| 234 | _OIter | 
|---|
| 235 | copy_if(_IIter, _IIter, _OIter, _Predicate); | 
|---|
| 236 |  | 
|---|
| 237 | template<typename _IIter, typename _Size, typename _OIter> | 
|---|
| 238 | _OIter | 
|---|
| 239 | copy_n(_IIter, _Size, _OIter); | 
|---|
| 240 | #endif | 
|---|
| 241 |  | 
|---|
| 242 | // count | 
|---|
| 243 | // count_if | 
|---|
| 244 |  | 
|---|
| 245 | template<typename _FIter, typename _Tp> | 
|---|
| 246 | pair<_FIter, _FIter> | 
|---|
| 247 | equal_range(_FIter, _FIter, const _Tp&); | 
|---|
| 248 |  | 
|---|
| 249 | template<typename _FIter, typename _Tp, typename _Compare> | 
|---|
| 250 | pair<_FIter, _FIter> | 
|---|
| 251 | equal_range(_FIter, _FIter, const _Tp&, _Compare); | 
|---|
| 252 |  | 
|---|
| 253 | template<typename _FIter, typename _Tp> | 
|---|
| 254 | void | 
|---|
| 255 | fill(_FIter, _FIter, const _Tp&); | 
|---|
| 256 |  | 
|---|
| 257 | template<typename _OIter, typename _Size, typename _Tp> | 
|---|
| 258 | _OIter | 
|---|
| 259 | fill_n(_OIter, _Size, const _Tp&); | 
|---|
| 260 |  | 
|---|
| 261 | // find | 
|---|
| 262 |  | 
|---|
| 263 | template<typename _FIter1, typename _FIter2> | 
|---|
| 264 | _FIter1 | 
|---|
| 265 | find_end(_FIter1, _FIter1, _FIter2, _FIter2); | 
|---|
| 266 |  | 
|---|
| 267 | template<typename _FIter1, typename _FIter2, typename _BinaryPredicate> | 
|---|
| 268 | _FIter1 | 
|---|
| 269 | find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); | 
|---|
| 270 |  | 
|---|
| 271 | // find_first_of | 
|---|
| 272 | // find_if | 
|---|
| 273 |  | 
|---|
| 274 | #if __cplusplus >= 201103L | 
|---|
| 275 | template<typename _IIter, typename _Predicate> | 
|---|
| 276 | _IIter | 
|---|
| 277 | find_if_not(_IIter, _IIter, _Predicate); | 
|---|
| 278 | #endif | 
|---|
| 279 |  | 
|---|
| 280 | // for_each | 
|---|
| 281 | // generate | 
|---|
| 282 | // generate_n | 
|---|
| 283 |  | 
|---|
| 284 | template<typename _IIter1, typename _IIter2> | 
|---|
| 285 | bool | 
|---|
| 286 | includes(_IIter1, _IIter1, _IIter2, _IIter2); | 
|---|
| 287 |  | 
|---|
| 288 | template<typename _IIter1, typename _IIter2, typename _Compare> | 
|---|
| 289 | bool | 
|---|
| 290 | includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); | 
|---|
| 291 |  | 
|---|
| 292 | template<typename _BIter> | 
|---|
| 293 | void | 
|---|
| 294 | inplace_merge(_BIter, _BIter, _BIter); | 
|---|
| 295 |  | 
|---|
| 296 | template<typename _BIter, typename _Compare> | 
|---|
| 297 | void | 
|---|
| 298 | inplace_merge(_BIter, _BIter, _BIter, _Compare); | 
|---|
| 299 |  | 
|---|
| 300 | #if __cplusplus >= 201103L | 
|---|
| 301 | template<typename _RAIter> | 
|---|
| 302 | bool | 
|---|
| 303 | is_heap(_RAIter, _RAIter); | 
|---|
| 304 |  | 
|---|
| 305 | template<typename _RAIter, typename _Compare> | 
|---|
| 306 | bool | 
|---|
| 307 | is_heap(_RAIter, _RAIter, _Compare); | 
|---|
| 308 |  | 
|---|
| 309 | template<typename _RAIter> | 
|---|
| 310 | _RAIter | 
|---|
| 311 | is_heap_until(_RAIter, _RAIter); | 
|---|
| 312 |  | 
|---|
| 313 | template<typename _RAIter, typename _Compare> | 
|---|
| 314 | _RAIter | 
|---|
| 315 | is_heap_until(_RAIter, _RAIter, _Compare); | 
|---|
| 316 |  | 
|---|
| 317 | template<typename _IIter, typename _Predicate> | 
|---|
| 318 | bool | 
|---|
| 319 | is_partitioned(_IIter, _IIter, _Predicate); | 
|---|
| 320 |  | 
|---|
| 321 | template<typename _FIter1, typename _FIter2> | 
|---|
| 322 | bool | 
|---|
| 323 | is_permutation(_FIter1, _FIter1, _FIter2); | 
|---|
| 324 |  | 
|---|
| 325 | template<typename _FIter1, typename _FIter2, | 
|---|
| 326 | typename _BinaryPredicate> | 
|---|
| 327 | bool | 
|---|
| 328 | is_permutation(_FIter1, _FIter1, _FIter2, _BinaryPredicate); | 
|---|
| 329 |  | 
|---|
| 330 | template<typename _FIter> | 
|---|
| 331 | bool | 
|---|
| 332 | is_sorted(_FIter, _FIter); | 
|---|
| 333 |  | 
|---|
| 334 | template<typename _FIter, typename _Compare> | 
|---|
| 335 | bool | 
|---|
| 336 | is_sorted(_FIter, _FIter, _Compare); | 
|---|
| 337 |  | 
|---|
| 338 | template<typename _FIter> | 
|---|
| 339 | _FIter | 
|---|
| 340 | is_sorted_until(_FIter, _FIter); | 
|---|
| 341 |  | 
|---|
| 342 | template<typename _FIter, typename _Compare> | 
|---|
| 343 | _FIter | 
|---|
| 344 | is_sorted_until(_FIter, _FIter, _Compare); | 
|---|
| 345 | #endif | 
|---|
| 346 |  | 
|---|
| 347 | template<typename _FIter1, typename _FIter2> | 
|---|
| 348 | void | 
|---|
| 349 | iter_swap(_FIter1, _FIter2); | 
|---|
| 350 |  | 
|---|
| 351 | template<typename _FIter, typename _Tp> | 
|---|
| 352 | _FIter | 
|---|
| 353 | lower_bound(_FIter, _FIter, const _Tp&); | 
|---|
| 354 |  | 
|---|
| 355 | template<typename _FIter, typename _Tp, typename _Compare> | 
|---|
| 356 | _FIter | 
|---|
| 357 | lower_bound(_FIter, _FIter, const _Tp&, _Compare); | 
|---|
| 358 |  | 
|---|
| 359 | template<typename _RAIter> | 
|---|
| 360 | void | 
|---|
| 361 | make_heap(_RAIter, _RAIter); | 
|---|
| 362 |  | 
|---|
| 363 | template<typename _RAIter, typename _Compare> | 
|---|
| 364 | void | 
|---|
| 365 | make_heap(_RAIter, _RAIter, _Compare); | 
|---|
| 366 |  | 
|---|
| 367 | template<typename _Tp> | 
|---|
| 368 | _GLIBCXX14_CONSTEXPR | 
|---|
| 369 | const _Tp& | 
|---|
| 370 | max(const _Tp&, const _Tp&); | 
|---|
| 371 |  | 
|---|
| 372 | template<typename _Tp, typename _Compare> | 
|---|
| 373 | _GLIBCXX14_CONSTEXPR | 
|---|
| 374 | const _Tp& | 
|---|
| 375 | max(const _Tp&, const _Tp&, _Compare); | 
|---|
| 376 |  | 
|---|
| 377 | // max_element | 
|---|
| 378 | // merge | 
|---|
| 379 |  | 
|---|
| 380 | template<typename _Tp> | 
|---|
| 381 | _GLIBCXX14_CONSTEXPR | 
|---|
| 382 | const _Tp& | 
|---|
| 383 | min(const _Tp&, const _Tp&); | 
|---|
| 384 |  | 
|---|
| 385 | template<typename _Tp, typename _Compare> | 
|---|
| 386 | _GLIBCXX14_CONSTEXPR | 
|---|
| 387 | const _Tp& | 
|---|
| 388 | min(const _Tp&, const _Tp&, _Compare); | 
|---|
| 389 |  | 
|---|
| 390 | // min_element | 
|---|
| 391 |  | 
|---|
| 392 | #if __cplusplus >= 201103L | 
|---|
| 393 | template<typename _Tp> | 
|---|
| 394 | _GLIBCXX14_CONSTEXPR | 
|---|
| 395 | pair<const _Tp&, const _Tp&> | 
|---|
| 396 | minmax(const _Tp&, const _Tp&); | 
|---|
| 397 |  | 
|---|
| 398 | template<typename _Tp, typename _Compare> | 
|---|
| 399 | _GLIBCXX14_CONSTEXPR | 
|---|
| 400 | pair<const _Tp&, const _Tp&> | 
|---|
| 401 | minmax(const _Tp&, const _Tp&, _Compare); | 
|---|
| 402 |  | 
|---|
| 403 | template<typename _FIter> | 
|---|
| 404 | _GLIBCXX14_CONSTEXPR | 
|---|
| 405 | pair<_FIter, _FIter> | 
|---|
| 406 | minmax_element(_FIter, _FIter); | 
|---|
| 407 |  | 
|---|
| 408 | template<typename _FIter, typename _Compare> | 
|---|
| 409 | _GLIBCXX14_CONSTEXPR | 
|---|
| 410 | pair<_FIter, _FIter> | 
|---|
| 411 | minmax_element(_FIter, _FIter, _Compare); | 
|---|
| 412 |  | 
|---|
| 413 | template<typename _Tp> | 
|---|
| 414 | _GLIBCXX14_CONSTEXPR | 
|---|
| 415 | _Tp | 
|---|
| 416 | min(initializer_list<_Tp>); | 
|---|
| 417 |  | 
|---|
| 418 | template<typename _Tp, typename _Compare> | 
|---|
| 419 | _GLIBCXX14_CONSTEXPR | 
|---|
| 420 | _Tp | 
|---|
| 421 | min(initializer_list<_Tp>, _Compare); | 
|---|
| 422 |  | 
|---|
| 423 | template<typename _Tp> | 
|---|
| 424 | _GLIBCXX14_CONSTEXPR | 
|---|
| 425 | _Tp | 
|---|
| 426 | max(initializer_list<_Tp>); | 
|---|
| 427 |  | 
|---|
| 428 | template<typename _Tp, typename _Compare> | 
|---|
| 429 | _GLIBCXX14_CONSTEXPR | 
|---|
| 430 | _Tp | 
|---|
| 431 | max(initializer_list<_Tp>, _Compare); | 
|---|
| 432 |  | 
|---|
| 433 | template<typename _Tp> | 
|---|
| 434 | _GLIBCXX14_CONSTEXPR | 
|---|
| 435 | pair<_Tp, _Tp> | 
|---|
| 436 | minmax(initializer_list<_Tp>); | 
|---|
| 437 |  | 
|---|
| 438 | template<typename _Tp, typename _Compare> | 
|---|
| 439 | _GLIBCXX14_CONSTEXPR | 
|---|
| 440 | pair<_Tp, _Tp> | 
|---|
| 441 | minmax(initializer_list<_Tp>, _Compare); | 
|---|
| 442 | #endif | 
|---|
| 443 |  | 
|---|
| 444 | // mismatch | 
|---|
| 445 |  | 
|---|
| 446 | template<typename _BIter> | 
|---|
| 447 | bool | 
|---|
| 448 | next_permutation(_BIter, _BIter); | 
|---|
| 449 |  | 
|---|
| 450 | template<typename _BIter, typename _Compare> | 
|---|
| 451 | bool | 
|---|
| 452 | next_permutation(_BIter, _BIter, _Compare); | 
|---|
| 453 |  | 
|---|
| 454 | #if __cplusplus >= 201103L | 
|---|
| 455 | template<typename _IIter, typename _Predicate> | 
|---|
| 456 | bool | 
|---|
| 457 | none_of(_IIter, _IIter, _Predicate); | 
|---|
| 458 | #endif | 
|---|
| 459 |  | 
|---|
| 460 | // nth_element | 
|---|
| 461 | // partial_sort | 
|---|
| 462 |  | 
|---|
| 463 | template<typename _IIter, typename _RAIter> | 
|---|
| 464 | _RAIter | 
|---|
| 465 | partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter); | 
|---|
| 466 |  | 
|---|
| 467 | template<typename _IIter, typename _RAIter, typename _Compare> | 
|---|
| 468 | _RAIter | 
|---|
| 469 | partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare); | 
|---|
| 470 |  | 
|---|
| 471 | // partition | 
|---|
| 472 |  | 
|---|
| 473 | #if __cplusplus >= 201103L | 
|---|
| 474 | template<typename _IIter, typename _OIter1, | 
|---|
| 475 | typename _OIter2, typename _Predicate> | 
|---|
| 476 | pair<_OIter1, _OIter2> | 
|---|
| 477 | partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate); | 
|---|
| 478 |  | 
|---|
| 479 | template<typename _FIter, typename _Predicate> | 
|---|
| 480 | _FIter | 
|---|
| 481 | partition_point(_FIter, _FIter, _Predicate); | 
|---|
| 482 | #endif | 
|---|
| 483 |  | 
|---|
| 484 | template<typename _RAIter> | 
|---|
| 485 | void | 
|---|
| 486 | pop_heap(_RAIter, _RAIter); | 
|---|
| 487 |  | 
|---|
| 488 | template<typename _RAIter, typename _Compare> | 
|---|
| 489 | void | 
|---|
| 490 | pop_heap(_RAIter, _RAIter, _Compare); | 
|---|
| 491 |  | 
|---|
| 492 | template<typename _BIter> | 
|---|
| 493 | bool | 
|---|
| 494 | prev_permutation(_BIter, _BIter); | 
|---|
| 495 |  | 
|---|
| 496 | template<typename _BIter, typename _Compare> | 
|---|
| 497 | bool | 
|---|
| 498 | prev_permutation(_BIter, _BIter, _Compare); | 
|---|
| 499 |  | 
|---|
| 500 | template<typename _RAIter> | 
|---|
| 501 | void | 
|---|
| 502 | push_heap(_RAIter, _RAIter); | 
|---|
| 503 |  | 
|---|
| 504 | template<typename _RAIter, typename _Compare> | 
|---|
| 505 | void | 
|---|
| 506 | push_heap(_RAIter, _RAIter, _Compare); | 
|---|
| 507 |  | 
|---|
| 508 | // random_shuffle | 
|---|
| 509 |  | 
|---|
| 510 | template<typename _FIter, typename _Tp> | 
|---|
| 511 | _FIter | 
|---|
| 512 | remove(_FIter, _FIter, const _Tp&); | 
|---|
| 513 |  | 
|---|
| 514 | template<typename _FIter, typename _Predicate> | 
|---|
| 515 | _FIter | 
|---|
| 516 | remove_if(_FIter, _FIter, _Predicate); | 
|---|
| 517 |  | 
|---|
| 518 | template<typename _IIter, typename _OIter, typename _Tp> | 
|---|
| 519 | _OIter | 
|---|
| 520 | remove_copy(_IIter, _IIter, _OIter, const _Tp&); | 
|---|
| 521 |  | 
|---|
| 522 | template<typename _IIter, typename _OIter, typename _Predicate> | 
|---|
| 523 | _OIter | 
|---|
| 524 | remove_copy_if(_IIter, _IIter, _OIter, _Predicate); | 
|---|
| 525 |  | 
|---|
| 526 | // replace | 
|---|
| 527 |  | 
|---|
| 528 | template<typename _IIter, typename _OIter, typename _Tp> | 
|---|
| 529 | _OIter | 
|---|
| 530 | replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&); | 
|---|
| 531 |  | 
|---|
| 532 | template<typename _Iter, typename _OIter, typename _Predicate, typename _Tp> | 
|---|
| 533 | _OIter | 
|---|
| 534 | replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&); | 
|---|
| 535 |  | 
|---|
| 536 | // replace_if | 
|---|
| 537 |  | 
|---|
| 538 | template<typename _BIter> | 
|---|
| 539 | void | 
|---|
| 540 | reverse(_BIter, _BIter); | 
|---|
| 541 |  | 
|---|
| 542 | template<typename _BIter, typename _OIter> | 
|---|
| 543 | _OIter | 
|---|
| 544 | reverse_copy(_BIter, _BIter, _OIter); | 
|---|
| 545 |  | 
|---|
| 546 | inline namespace _V2 | 
|---|
| 547 | { | 
|---|
| 548 | template<typename _FIter> | 
|---|
| 549 | _FIter | 
|---|
| 550 | rotate(_FIter, _FIter, _FIter); | 
|---|
| 551 | } | 
|---|
| 552 |  | 
|---|
| 553 | template<typename _FIter, typename _OIter> | 
|---|
| 554 | _OIter | 
|---|
| 555 | rotate_copy(_FIter, _FIter, _FIter, _OIter); | 
|---|
| 556 |  | 
|---|
| 557 | // search | 
|---|
| 558 | // search_n | 
|---|
| 559 | // set_difference | 
|---|
| 560 | // set_intersection | 
|---|
| 561 | // set_symmetric_difference | 
|---|
| 562 | // set_union | 
|---|
| 563 |  | 
|---|
| 564 | #if (__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99_STDINT_TR1) | 
|---|
| 565 | template<typename _RAIter, typename _UGenerator> | 
|---|
| 566 | void | 
|---|
| 567 | shuffle(_RAIter, _RAIter, _UGenerator&&); | 
|---|
| 568 | #endif | 
|---|
| 569 |  | 
|---|
| 570 | template<typename _RAIter> | 
|---|
| 571 | void | 
|---|
| 572 | sort_heap(_RAIter, _RAIter); | 
|---|
| 573 |  | 
|---|
| 574 | template<typename _RAIter, typename _Compare> | 
|---|
| 575 | void | 
|---|
| 576 | sort_heap(_RAIter, _RAIter, _Compare); | 
|---|
| 577 |  | 
|---|
| 578 | template<typename _BIter, typename _Predicate> | 
|---|
| 579 | _BIter | 
|---|
| 580 | stable_partition(_BIter, _BIter, _Predicate); | 
|---|
| 581 |  | 
|---|
| 582 | #if __cplusplus < 201103L | 
|---|
| 583 | // For C++11 swap() is declared in <type_traits>. | 
|---|
| 584 |  | 
|---|
| 585 | template<typename _Tp, size_t _Nm> | 
|---|
| 586 | inline void | 
|---|
| 587 | swap(_Tp& __a, _Tp& __b); | 
|---|
| 588 |  | 
|---|
| 589 | template<typename _Tp, size_t _Nm> | 
|---|
| 590 | inline void | 
|---|
| 591 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]); | 
|---|
| 592 | #endif | 
|---|
| 593 |  | 
|---|
| 594 | template<typename _FIter1, typename _FIter2> | 
|---|
| 595 | _FIter2 | 
|---|
| 596 | swap_ranges(_FIter1, _FIter1, _FIter2); | 
|---|
| 597 |  | 
|---|
| 598 | // transform | 
|---|
| 599 |  | 
|---|
| 600 | template<typename _FIter> | 
|---|
| 601 | _FIter | 
|---|
| 602 | unique(_FIter, _FIter); | 
|---|
| 603 |  | 
|---|
| 604 | template<typename _FIter, typename _BinaryPredicate> | 
|---|
| 605 | _FIter | 
|---|
| 606 | unique(_FIter, _FIter, _BinaryPredicate); | 
|---|
| 607 |  | 
|---|
| 608 | // unique_copy | 
|---|
| 609 |  | 
|---|
| 610 | template<typename _FIter, typename _Tp> | 
|---|
| 611 | _FIter | 
|---|
| 612 | upper_bound(_FIter, _FIter, const _Tp&); | 
|---|
| 613 |  | 
|---|
| 614 | template<typename _FIter, typename _Tp, typename _Compare> | 
|---|
| 615 | _FIter | 
|---|
| 616 | upper_bound(_FIter, _FIter, const _Tp&, _Compare); | 
|---|
| 617 |  | 
|---|
| 618 | _GLIBCXX_BEGIN_NAMESPACE_ALGO | 
|---|
| 619 |  | 
|---|
| 620 | template<typename _FIter> | 
|---|
| 621 | _FIter | 
|---|
| 622 | adjacent_find(_FIter, _FIter); | 
|---|
| 623 |  | 
|---|
| 624 | template<typename _FIter, typename _BinaryPredicate> | 
|---|
| 625 | _FIter | 
|---|
| 626 | adjacent_find(_FIter, _FIter, _BinaryPredicate); | 
|---|
| 627 |  | 
|---|
| 628 | template<typename _IIter, typename _Tp> | 
|---|
| 629 | typename iterator_traits<_IIter>::difference_type | 
|---|
| 630 | count(_IIter, _IIter, const _Tp&); | 
|---|
| 631 |  | 
|---|
| 632 | template<typename _IIter, typename _Predicate> | 
|---|
| 633 | typename iterator_traits<_IIter>::difference_type | 
|---|
| 634 | count_if(_IIter, _IIter, _Predicate); | 
|---|
| 635 |  | 
|---|
| 636 | template<typename _IIter1, typename _IIter2> | 
|---|
| 637 | bool | 
|---|
| 638 | equal(_IIter1, _IIter1, _IIter2); | 
|---|
| 639 |  | 
|---|
| 640 | template<typename _IIter1, typename _IIter2, typename _BinaryPredicate> | 
|---|
| 641 | bool | 
|---|
| 642 | equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate); | 
|---|
| 643 |  | 
|---|
| 644 | template<typename _IIter, typename _Tp> | 
|---|
| 645 | _IIter | 
|---|
| 646 | find(_IIter, _IIter, const _Tp&); | 
|---|
| 647 |  | 
|---|
| 648 | template<typename _FIter1, typename _FIter2> | 
|---|
| 649 | _FIter1 | 
|---|
| 650 | find_first_of(_FIter1, _FIter1, _FIter2, _FIter2); | 
|---|
| 651 |  | 
|---|
| 652 | template<typename _FIter1, typename _FIter2, typename _BinaryPredicate> | 
|---|
| 653 | _FIter1 | 
|---|
| 654 | find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); | 
|---|
| 655 |  | 
|---|
| 656 | template<typename _IIter, typename _Predicate> | 
|---|
| 657 | _IIter | 
|---|
| 658 | find_if(_IIter, _IIter, _Predicate); | 
|---|
| 659 |  | 
|---|
| 660 | template<typename _IIter, typename _Funct> | 
|---|
| 661 | _Funct | 
|---|
| 662 | for_each(_IIter, _IIter, _Funct); | 
|---|
| 663 |  | 
|---|
| 664 | template<typename _FIter, typename _Generator> | 
|---|
| 665 | void | 
|---|
| 666 | generate(_FIter, _FIter, _Generator); | 
|---|
| 667 |  | 
|---|
| 668 | template<typename _OIter, typename _Size, typename _Generator> | 
|---|
| 669 | _OIter | 
|---|
| 670 | generate_n(_OIter, _Size, _Generator); | 
|---|
| 671 |  | 
|---|
| 672 | template<typename _IIter1, typename _IIter2> | 
|---|
| 673 | bool | 
|---|
| 674 | lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2); | 
|---|
| 675 |  | 
|---|
| 676 | template<typename _IIter1, typename _IIter2, typename _Compare> | 
|---|
| 677 | bool | 
|---|
| 678 | lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); | 
|---|
| 679 |  | 
|---|
| 680 | template<typename _FIter> | 
|---|
| 681 | _GLIBCXX14_CONSTEXPR | 
|---|
| 682 | _FIter | 
|---|
| 683 | max_element(_FIter, _FIter); | 
|---|
| 684 |  | 
|---|
| 685 | template<typename _FIter, typename _Compare> | 
|---|
| 686 | _GLIBCXX14_CONSTEXPR | 
|---|
| 687 | _FIter | 
|---|
| 688 | max_element(_FIter, _FIter, _Compare); | 
|---|
| 689 |  | 
|---|
| 690 | template<typename _IIter1, typename _IIter2, typename _OIter> | 
|---|
| 691 | _OIter | 
|---|
| 692 | merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); | 
|---|
| 693 |  | 
|---|
| 694 | template<typename _IIter1, typename _IIter2, typename _OIter, | 
|---|
| 695 | typename _Compare> | 
|---|
| 696 | _OIter | 
|---|
| 697 | merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); | 
|---|
| 698 |  | 
|---|
| 699 | template<typename _FIter> | 
|---|
| 700 | _GLIBCXX14_CONSTEXPR | 
|---|
| 701 | _FIter | 
|---|
| 702 | min_element(_FIter, _FIter); | 
|---|
| 703 |  | 
|---|
| 704 | template<typename _FIter, typename _Compare> | 
|---|
| 705 | _GLIBCXX14_CONSTEXPR | 
|---|
| 706 | _FIter | 
|---|
| 707 | min_element(_FIter, _FIter, _Compare); | 
|---|
| 708 |  | 
|---|
| 709 | template<typename _IIter1, typename _IIter2> | 
|---|
| 710 | pair<_IIter1, _IIter2> | 
|---|
| 711 | mismatch(_IIter1, _IIter1, _IIter2); | 
|---|
| 712 |  | 
|---|
| 713 | template<typename _IIter1, typename _IIter2, typename _BinaryPredicate> | 
|---|
| 714 | pair<_IIter1, _IIter2> | 
|---|
| 715 | mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate); | 
|---|
| 716 |  | 
|---|
| 717 | template<typename _RAIter> | 
|---|
| 718 | void | 
|---|
| 719 | nth_element(_RAIter, _RAIter, _RAIter); | 
|---|
| 720 |  | 
|---|
| 721 | template<typename _RAIter, typename _Compare> | 
|---|
| 722 | void | 
|---|
| 723 | nth_element(_RAIter, _RAIter, _RAIter, _Compare); | 
|---|
| 724 |  | 
|---|
| 725 | template<typename _RAIter> | 
|---|
| 726 | void | 
|---|
| 727 | partial_sort(_RAIter, _RAIter, _RAIter); | 
|---|
| 728 |  | 
|---|
| 729 | template<typename _RAIter, typename _Compare> | 
|---|
| 730 | void | 
|---|
| 731 | partial_sort(_RAIter, _RAIter, _RAIter, _Compare); | 
|---|
| 732 |  | 
|---|
| 733 | template<typename _BIter, typename _Predicate> | 
|---|
| 734 | _BIter | 
|---|
| 735 | partition(_BIter, _BIter, _Predicate); | 
|---|
| 736 |  | 
|---|
| 737 | template<typename _RAIter> | 
|---|
| 738 | void | 
|---|
| 739 | random_shuffle(_RAIter, _RAIter); | 
|---|
| 740 |  | 
|---|
| 741 | template<typename _RAIter, typename _Generator> | 
|---|
| 742 | void | 
|---|
| 743 | random_shuffle(_RAIter, _RAIter, | 
|---|
| 744 | #if __cplusplus >= 201103L | 
|---|
| 745 | _Generator&&); | 
|---|
| 746 | #else | 
|---|
| 747 | _Generator&); | 
|---|
| 748 | #endif | 
|---|
| 749 |  | 
|---|
| 750 | template<typename _FIter, typename _Tp> | 
|---|
| 751 | void | 
|---|
| 752 | replace(_FIter, _FIter, const _Tp&, const _Tp&); | 
|---|
| 753 |  | 
|---|
| 754 | template<typename _FIter, typename _Predicate, typename _Tp> | 
|---|
| 755 | void | 
|---|
| 756 | replace_if(_FIter, _FIter, _Predicate, const _Tp&); | 
|---|
| 757 |  | 
|---|
| 758 | template<typename _FIter1, typename _FIter2> | 
|---|
| 759 | _FIter1 | 
|---|
| 760 | search(_FIter1, _FIter1, _FIter2, _FIter2); | 
|---|
| 761 |  | 
|---|
| 762 | template<typename _FIter1, typename _FIter2, typename _BinaryPredicate> | 
|---|
| 763 | _FIter1 | 
|---|
| 764 | search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); | 
|---|
| 765 |  | 
|---|
| 766 | template<typename _FIter, typename _Size, typename _Tp> | 
|---|
| 767 | _FIter | 
|---|
| 768 | search_n(_FIter, _FIter, _Size, const _Tp&); | 
|---|
| 769 |  | 
|---|
| 770 | template<typename _FIter, typename _Size, typename _Tp, | 
|---|
| 771 | typename _BinaryPredicate> | 
|---|
| 772 | _FIter | 
|---|
| 773 | search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate); | 
|---|
| 774 |  | 
|---|
| 775 | template<typename _IIter1, typename _IIter2, typename _OIter> | 
|---|
| 776 | _OIter | 
|---|
| 777 | set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); | 
|---|
| 778 |  | 
|---|
| 779 | template<typename _IIter1, typename _IIter2, typename _OIter, | 
|---|
| 780 | typename _Compare> | 
|---|
| 781 | _OIter | 
|---|
| 782 | set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); | 
|---|
| 783 |  | 
|---|
| 784 | template<typename _IIter1, typename _IIter2, typename _OIter> | 
|---|
| 785 | _OIter | 
|---|
| 786 | set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); | 
|---|
| 787 |  | 
|---|
| 788 | template<typename _IIter1, typename _IIter2, typename _OIter, | 
|---|
| 789 | typename _Compare> | 
|---|
| 790 | _OIter | 
|---|
| 791 | set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); | 
|---|
| 792 |  | 
|---|
| 793 | template<typename _IIter1, typename _IIter2, typename _OIter> | 
|---|
| 794 | _OIter | 
|---|
| 795 | set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); | 
|---|
| 796 |  | 
|---|
| 797 | template<typename _IIter1, typename _IIter2, typename _OIter, | 
|---|
| 798 | typename _Compare> | 
|---|
| 799 | _OIter | 
|---|
| 800 | set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, | 
|---|
| 801 | _OIter, _Compare); | 
|---|
| 802 |  | 
|---|
| 803 | template<typename _IIter1, typename _IIter2, typename _OIter> | 
|---|
| 804 | _OIter | 
|---|
| 805 | set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); | 
|---|
| 806 |  | 
|---|
| 807 | template<typename _IIter1, typename _IIter2, typename _OIter, | 
|---|
| 808 | typename _Compare> | 
|---|
| 809 | _OIter | 
|---|
| 810 | set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); | 
|---|
| 811 |  | 
|---|
| 812 | template<typename _RAIter> | 
|---|
| 813 | void | 
|---|
| 814 | sort(_RAIter, _RAIter); | 
|---|
| 815 |  | 
|---|
| 816 | template<typename _RAIter, typename _Compare> | 
|---|
| 817 | void | 
|---|
| 818 | sort(_RAIter, _RAIter, _Compare); | 
|---|
| 819 |  | 
|---|
| 820 | template<typename _RAIter> | 
|---|
| 821 | void | 
|---|
| 822 | stable_sort(_RAIter, _RAIter); | 
|---|
| 823 |  | 
|---|
| 824 | template<typename _RAIter, typename _Compare> | 
|---|
| 825 | void | 
|---|
| 826 | stable_sort(_RAIter, _RAIter, _Compare); | 
|---|
| 827 |  | 
|---|
| 828 | template<typename _IIter, typename _OIter, typename _UnaryOperation> | 
|---|
| 829 | _OIter | 
|---|
| 830 | transform(_IIter, _IIter, _OIter, _UnaryOperation); | 
|---|
| 831 |  | 
|---|
| 832 | template<typename _IIter1, typename _IIter2, typename _OIter, | 
|---|
| 833 | typename _BinaryOperation> | 
|---|
| 834 | _OIter | 
|---|
| 835 | transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation); | 
|---|
| 836 |  | 
|---|
| 837 | template<typename _IIter, typename _OIter> | 
|---|
| 838 | _OIter | 
|---|
| 839 | unique_copy(_IIter, _IIter, _OIter); | 
|---|
| 840 |  | 
|---|
| 841 | template<typename _IIter, typename _OIter, typename _BinaryPredicate> | 
|---|
| 842 | _OIter | 
|---|
| 843 | unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate); | 
|---|
| 844 |  | 
|---|
| 845 | _GLIBCXX_END_NAMESPACE_ALGO | 
|---|
| 846 | _GLIBCXX_END_NAMESPACE_VERSION | 
|---|
| 847 | } // namespace std | 
|---|
| 848 |  | 
|---|
| 849 | #ifdef _GLIBCXX_PARALLEL | 
|---|
| 850 | # include <parallel/algorithmfwd.h> | 
|---|
| 851 | #endif | 
|---|
| 852 |  | 
|---|
| 853 | #endif | 
|---|
| 854 |  | 
|---|
| 855 |  | 
|---|