00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef LASS_GUARDIAN_OF_INCLUSION_STDE_RANGE_ALGORITHM_H
00051 #define LASS_GUARDIAN_OF_INCLUSION_STDE_RANGE_ALGORITHM_H
00052
00053 #include "stde_common.h"
00054
00055 #if LASS_COMPILER_TYPE == LASS_COMPILER_TYPE_MSVC
00056 # pragma warning(push)
00057 # pragma warning(disable: 4996)
00058 #endif
00059
00060 namespace lass
00061 {
00062 namespace stde
00063 {
00064
00065
00066
00067
00068 template <typename InputRange, typename Op> inline
00069 Op for_each_r(InputRange& range, Op op)
00070 {
00071 return std::for_each(range.begin(), range.end(), op);
00072 }
00073
00074
00075
00076
00077 template <typename InputRange, typename T> inline
00078 typename InputRange::iterator
00079 find_r(const InputRange& range, const T& value)
00080 {
00081 return std::find(range.begin(), range.end(), value);
00082 }
00083
00084
00085
00086
00087 template <typename InputRange, typename Predicate> inline
00088 typename InputRange::iterator
00089 find_if_r(const InputRange& range, Predicate pred)
00090 {
00091 return std::find(range.begin(), range.end(), pred);
00092 }
00093
00094
00095
00096
00097 template <typename ForwardRange1, typename ForwardRange2> inline
00098 typename ForwardRange1::iterator
00099 find_end_r(const ForwardRange1& range1, const ForwardRange2& range2)
00100 {
00101 return std::find_end(range1.begin(), range1.end(), range2.begin(), range2.end());
00102 }
00103
00104
00105
00106
00107 template <typename ForwardRange1, typename ForwardRange2, typename BinaryPredicate> inline
00108 typename ForwardRange1::iterator
00109 find_end_r(const ForwardRange1& range1, const ForwardRange2& range2, BinaryPredicate pred)
00110 {
00111 return std::find_end(range1.begin(), range1.end(), range2.begin(), range2.end(), pred);
00112 }
00113
00114
00115
00116
00117 template <typename ForwardRange1, typename ForwardRange2> inline
00118 typename ForwardRange1::iterator
00119 find_first_of_r(const ForwardRange1& range1, const ForwardRange2& range2)
00120 {
00121 return std::find_first_of(range1.begin(), range1.end(), range2.begin(), range2.end());
00122 }
00123
00124
00125
00126
00127 template <typename ForwardRange1, typename ForwardRange2, typename BinaryPredicate> inline
00128 typename ForwardRange1::iterator
00129 find_first_of_r(const ForwardRange1& range1,const ForwardRange2& range2, BinaryPredicate pred)
00130 {
00131 return std::find_first_of(range1.begin(), range1.end(), range2.begin(), range2.end(), pred);
00132 }
00133
00134
00135
00136
00137 template <typename ForwardRange> inline
00138 typename ForwardRange::iterator
00139 adjacent_find_r(const ForwardRange& range)
00140 {
00141 return std::adjacent_find(range.begin(), range.end());
00142 }
00143
00144
00145
00146
00147 template <typename ForwardRange, typename Predicate> inline
00148 typename ForwardRange::iterator
00149 adjacent_find_r(const ForwardRange& range, Predicate pred)
00150 {
00151 return std::adjacent_find(range.begin(), range.end(), pred);
00152 }
00153
00154
00155
00156
00157 template <typename InputRange, typename T> inline
00158 typename std::iterator_traits<typename InputRange::iterator>::difference_type
00159 count_r(const InputRange& range, const T& value)
00160 {
00161 return std::count(range.begin(), range.end(), value);
00162 }
00163
00164
00165
00166
00167 template <typename InputRange, typename Predicate> inline
00168 typename std::iterator_traits<typename InputRange::iterator>::difference_type
00169 count_if_r(const InputRange& range, Predicate pred)
00170 {
00171 return std::count_if(range.begin(), range.end(), pred);
00172 }
00173
00174
00175
00176
00177 template <typename InputRange1, typename InputRange2, typename BinaryPredicate> inline
00178 std::pair<typename InputRange1::iterator, typename InputRange2::iterator>
00179 mismatch_r(const InputRange1& range1, const InputRange2& range2, BinaryPredicate pred)
00180 {
00181 return std::mismatch(range1.begin(), range1.end(), range2.begin(), range2.end(), pred);
00182 }
00183
00184
00185
00186
00187 template <typename InputRange1, typename InputRange2> inline
00188 std::pair<typename InputRange1::iterator, typename InputRange2::iterator>
00189 mismatch_r(const InputRange1& range1, const InputRange2& range2)
00190 {
00191 return std::mismatch(range1.begin(), range1.end(), range2.begin(), range2.end());
00192 }
00193
00194
00195
00196
00197 template <typename InputRange1, typename InputRange2> inline
00198 bool equal_r(const InputRange1& range1, const InputRange2& range2)
00199 {
00200 return std::equal(range1.begin(), range1.end(), range2.begin());
00201 }
00202
00203
00204
00205
00206 template <typename InputRange1, typename InputRange2, typename BinaryPredicate> inline
00207 bool equal_r(const InputRange1& range1, const InputRange2& range2, BinaryPredicate pred)
00208 {
00209 return std::equal(range1.begin(), range1.end(), range2.begin(), pred);
00210 }
00211
00212
00213
00214
00215 template <typename ForwardRange1, typename ForwardRange2> inline
00216 typename ForwardRange1::iterator
00217 search_r(const ForwardRange1& range1,const ForwardRange2& range2)
00218 {
00219 return std::search(range1.begin(), range1.end(), range2.begin(), range2.end());
00220 }
00221
00222
00223
00224
00225 template <typename ForwardRange1, typename ForwardRange2, typename BinaryPredicate> inline
00226 typename ForwardRange1::iterator
00227 search_r(const ForwardRange1& range1,const ForwardRange2& range2, BinaryPredicate pred)
00228 {
00229 return std::search(range1.begin(), range1.end(), range2.begin(), range2.end(), pred);
00230 }
00231
00232
00233
00234
00235 template <typename ForwardRange, typename Size, typename T> inline
00236 typename ForwardRange::iterator
00237 search_n_r(const ForwardRange& range, Size count, const T& value)
00238 {
00239 return std::search_n(range.begin(), range.end(), count, value);
00240 }
00241
00242
00243
00244
00245 template <typename ForwardRange, typename Size, typename T, typename BinaryPredicate> inline
00246 typename ForwardRange::iterator
00247 search_n_r(const ForwardRange& range, Size count, const T& value, BinaryPredicate pred)
00248 {
00249 return std::search_n(range.begin(), range.end(), count, value, pred);
00250 }
00251
00252
00253
00254
00255 template <typename InputRange, typename OutputIterator> inline
00256 OutputIterator copy_r(const InputRange& range, OutputIterator result)
00257 {
00258 return std::copy(range.begin(), range.end(), result);
00259 }
00260
00261
00262
00263
00264 template <typename BidirectionalRange, typename BidirectionalIterator> inline
00265 BidirectionalIterator copy_backward_r(const BidirectionalRange& range, BidirectionalIterator result)
00266 {
00267 return std::copy_backward(range.begin(), range.end(), result);
00268 }
00269
00270
00271
00272
00273 template <typename ForwardRange1, typename ForwardRange2> inline
00274 typename ForwardRange2::iterator
00275 swap_ranges_r(ForwardRange1& range1, ForwardRange2& range2)
00276 {
00277 return std::swap_ranges(range1.begin(), range1.end(), range2.begin());
00278 }
00279
00280
00281
00282
00283 template <typename InputRange, typename OutputIterator, typename UnaryOperation> inline
00284 OutputIterator transform_r(const InputRange& range, OutputIterator result, UnaryOperation op)
00285 {
00286 return std::transform(range.begin(), range.end(), result, op);
00287 }
00288
00289
00290
00291
00292 template <typename InputRange1, typename InputRange2, typename OutputIterator, typename BinaryOperation> inline
00293 OutputIterator transform_r(const InputRange1& range1, const InputRange2& range2, OutputIterator result, BinaryOperation op)
00294 {
00295 return std::transform(range1.begin(), range1.end(), range2.begin(), range2.end(), result, op);
00296 }
00297
00298
00299
00300
00301 template <typename ForwardRange, typename T> inline
00302 void replace_r(ForwardRange& range, const T& old_value, const T& new_value)
00303 {
00304 std::replace(range.begin(), range.end(), old_value, new_value);
00305 }
00306
00307
00308
00309
00310 template <typename ForwardRange, typename Predicate, typename T> inline
00311 void replace_if_r(ForwardRange& range, Predicate pred, const T& new_value)
00312 {
00313 std::replace_if(range.begin(), range.end(), pred, new_value);
00314 }
00315
00316
00317
00318
00319 template <typename InputRange, typename OutputIterator, typename T> inline
00320 OutputIterator replace_copy_r(const InputRange& range, OutputIterator result, const T& old_value, const T& new_value)
00321 {
00322 return std::replace(range.begin(), range.end(), result, old_value, new_value);
00323 }
00324
00325
00326
00327
00328 template <typename InputRange, typename OutputIterator, typename Predicate, typename T> inline
00329 OutputIterator replace_copy_if_r(const InputRange& range, OutputIterator result, Predicate pred, const T& new_value)
00330 {
00331 return std::replace_if(range.begin(), range.end(), result, pred, new_value);
00332 }
00333
00334
00335
00336
00337 template <typename ForwardRange, typename T> inline
00338 void fill_r(ForwardRange& range, const T& value)
00339 {
00340 std::fill(range.begin(), range.end(), value);
00341 }
00342
00343
00344
00345
00346 template <typename ForwardRange, typename Generator> inline
00347 void generate_r(ForwardRange& range, Generator gen)
00348 {
00349 std::generate(range.begin(), range.end(), gen);
00350 }
00351
00352
00353
00354
00355 template <typename ForwardRange, typename T> inline
00356 typename ForwardRange::iterator
00357 remove_r(ForwardRange& range, const T& value)
00358 {
00359 return std::remove(range.begin(), range.end(), value);
00360 }
00361
00362
00363
00364
00365 template <typename ForwardRange, typename Predicate> inline
00366 typename ForwardRange::iterator
00367 remove_if_r(ForwardRange& range, Predicate pred)
00368 {
00369 return std::remove_if(range.begin(), range.end(), pred);
00370 }
00371
00372
00373
00374
00375 template <typename InputRange, typename OutputIterator, typename T> inline
00376 OutputIterator remove_copy_r(const InputRange& range, OutputIterator result, const T& value)
00377 {
00378 return std::remove_copy(range.begin(), range.end(), result, value);
00379 }
00380
00381
00382
00383
00384 template <typename InputRange, typename OutputIterator, typename Predicate> inline
00385 OutputIterator remove_copy_if_r(const InputRange& range, OutputIterator result, Predicate pred)
00386 {
00387 return std::remove_copy_if(range.begin(), range.end(), result, pred);
00388 }
00389
00390
00391
00392
00393 template <typename ForwardRange> inline
00394 typename ForwardRange::iterator
00395 unique_r(ForwardRange& range)
00396 {
00397 return std::unique(range.begin(), range.end());
00398 }
00399
00400
00401
00402
00403 template <typename ForwardRange, typename Predicate> inline
00404 typename ForwardRange::iterator
00405 unique_r(ForwardRange& range, Predicate pred)
00406 {
00407 return std::unique(range.begin(), range.end(), pred);
00408 }
00409
00410
00411
00412
00413 template <typename InputRange, typename OutputIterator> inline
00414 OutputIterator unique_copy_r(const InputRange& range, OutputIterator result)
00415 {
00416 return std::unique_copy(range.begin(), range.end(), result);
00417 }
00418
00419
00420
00421
00422 template <typename InputRange, typename OutputIterator, typename Predicate> inline
00423 OutputIterator unique_copy_r(const InputRange& range, OutputIterator result, Predicate pred)
00424 {
00425 return std::unique_copy(range.begin(), range.end(), result, pred);
00426 }
00427
00428
00429
00430
00431 template <typename BidirectionalRange> inline
00432 void reverse_r(BidirectionalRange& range)
00433 {
00434 std::reverse(range.begin(), range.end());
00435 }
00436
00437
00438
00439
00440 template <typename BidirectionalRange, typename OutputIterator> inline
00441 OutputIterator reverse_copy_r(const BidirectionalRange& range, OutputIterator result)
00442 {
00443 return std::reverse_copy(range.begin(), range.end(), result);
00444 }
00445
00446
00447
00448
00449 template <typename ForwardRange> inline
00450 void rotate_r(ForwardRange& range, typename ForwardRange::iterator middle)
00451 {
00452 return std::rotate(range.begin(), middle, range.end());
00453 }
00454
00455
00456
00457
00458 template <typename ForwardRange, typename OutputIterator> inline
00459 void rotate_copy_r(const ForwardRange& range, typename ForwardRange::iterator middle, OutputIterator result)
00460 {
00461 return std::rotate_copy(range.begin(), middle, range.end(), result);
00462 }
00463
00464
00465
00466
00467 template <typename RandomAccessRange> inline
00468 void random_shuffle_r(RandomAccessRange& range)
00469 {
00470 return std::random_shuffle(range.begin(), range.end());
00471 }
00472
00473
00474
00475
00476
00477 template <typename RandomAccessRange, typename RandomNumberGenerator> inline
00478 void random_shuffle_r(RandomAccessRange& range, RandomNumberGenerator& rand)
00479 {
00480 return std::random_shuffle(range.begin(), range.end(), rand);
00481 }
00482
00483
00484
00485
00486 template <typename BidirectionalRange, typename Predicate>
00487 typename BidirectionalRange::iterator
00488 partition_r(BidirectionalRange& range, Predicate pred)
00489 {
00490 return std::partition(range.begin(), range.end(), pred);
00491 }
00492
00493
00494
00495
00496 template <typename BidirectionalRange, typename Predicate>
00497 typename BidirectionalRange::iterator
00498 stable_partition_r(BidirectionalRange& range, Predicate pred)
00499 {
00500 return std::stable_partition(range.begin(), range.end(), pred);
00501 }
00502
00503 }
00504
00505 }
00506
00507 #if LASS_COMPILER_TYPE == LASS_COMPILER_TYPE_MSVC
00508 # pragma warning(pop)
00509 #endif
00510
00511 #endif
00512
00513