Merge from mainline (160224:163495).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / include / bits / algorithmfwd.h
blobcf541bc28aa3895cc5e1e4c3e386dae0768febb4
1 // <algorithm> declarations -*- C++ -*-
3 // Copyright (C) 2007, 2008, 2009, 2010 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.
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.
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.
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/>.
25 /** @file bits/algorithmfwd.h
26 * This is an internal header file, included by other library headers.
27 * You should not attempt to use it directly.
30 #ifndef _GLIBCXX_ALGORITHMFWD_H
31 #define _GLIBCXX_ALGORITHMFWD_H 1
33 #pragma GCC system_header
35 #include <bits/c++config.h>
36 #include <bits/stl_pair.h>
37 #include <bits/stl_iterator_base_types.h>
38 #include <initializer_list>
40 _GLIBCXX_BEGIN_NAMESPACE(std)
43 adjacent_find
44 all_of (C++0x)
45 any_of (C++0x)
46 binary_search
47 copy
48 copy_backward
49 copy_if (C++0x)
50 copy_n (C++0x)
51 count
52 count_if
53 equal
54 equal_range
55 fill
56 fill_n
57 find
58 find_end
59 find_first_of
60 find_if
61 find_if_not (C++0x)
62 for_each
63 generate
64 generate_n
65 includes
66 inplace_merge
67 is_heap (C++0x)
68 is_heap_until (C++0x)
69 is_partitioned (C++0x)
70 is_sorted (C++0x)
71 is_sorted_until (C++0x)
72 iter_swap
73 lexicographical_compare
74 lower_bound
75 make_heap
76 max
77 max_element
78 merge
79 min
80 min_element
81 minmax (C++0x)
82 minmax_element (C++0x)
83 mismatch
84 next_permutation
85 none_of (C++0x)
86 nth_element
87 partial_sort
88 partial_sort_copy
89 partition
90 partition_copy (C++0x)
91 partition_point (C++0x)
92 pop_heap
93 prev_permutation
94 push_heap
95 random_shuffle
96 remove
97 remove_copy
98 remove_copy_if
99 remove_if
100 replace
101 replace_copy
102 replace_copy_if
103 replace_if
104 reverse
105 reverse_copy
106 rotate
107 rotate_copy
108 search
109 search_n
110 set_difference
111 set_intersection
112 set_symmetric_difference
113 set_union
114 shuffle (C++0x)
115 sort
116 sort_heap
117 stable_partition
118 stable_sort
119 swap
120 swap_ranges
121 transform
122 unique
123 unique_copy
124 upper_bound
128 * @defgroup algorithms Algorithms
130 * Components for performing algorithmic operations. Includes
131 * non-modifying sequence, modifying (mutating) sequence, sorting,
132 * searching, merge, partition, heap, set, minima, maxima, and
133 * permutation operations.
137 * @defgroup mutating_algorithms Mutating
138 * @ingroup algorithms
142 * @defgroup non_mutating_algorithms Non-Mutating
143 * @ingroup algorithms
147 * @defgroup sorting_algorithms Sorting
148 * @ingroup algorithms
152 * @defgroup set_algorithms Set Operation
153 * @ingroup sorting_algorithms
155 * These algorithms are common set operations performed on sequences
156 * that are already sorted. The number of comparisons will be
157 * linear.
161 * @defgroup binary_search_algorithms Binary Search
162 * @ingroup sorting_algorithms
164 * These algorithms are variations of a classic binary search, and
165 * all assume that the sequence being searched is already sorted.
167 * The number of comparisons will be logarithmic (and as few as
168 * possible). The number of steps through the sequence will be
169 * logarithmic for random-access iterators (e.g., pointers), and
170 * linear otherwise.
172 * The LWG has passed Defect Report 270, which notes: <em>The
173 * proposed resolution reinterprets binary search. Instead of
174 * thinking about searching for a value in a sorted range, we view
175 * that as an important special case of a more general algorithm:
176 * searching for the partition point in a partitioned range. We
177 * also add a guarantee that the old wording did not: we ensure that
178 * the upper bound is no earlier than the lower bound, that the pair
179 * returned by equal_range is a valid range, and that the first part
180 * of that pair is the lower bound.</em>
182 * The actual effect of the first sentence is that a comparison
183 * functor passed by the user doesn't necessarily need to induce a
184 * strict weak ordering relation. Rather, it partitions the range.
187 // adjacent_find
189 #ifdef __GXX_EXPERIMENTAL_CXX0X__
190 template<typename _IIter, typename _Predicate>
191 bool
192 all_of(_IIter, _IIter, _Predicate);
194 template<typename _IIter, typename _Predicate>
195 bool
196 any_of(_IIter, _IIter, _Predicate);
197 #endif
199 template<typename _FIter, typename _Tp>
200 bool
201 binary_search(_FIter, _FIter, const _Tp&);
203 template<typename _FIter, typename _Tp, typename _Compare>
204 bool
205 binary_search(_FIter, _FIter, const _Tp&, _Compare);
207 template<typename _IIter, typename _OIter>
208 _OIter
209 copy(_IIter, _IIter, _OIter);
211 template<typename _BIter1, typename _BIter2>
212 _BIter2
213 copy_backward(_BIter1, _BIter1, _BIter2);
215 #ifdef __GXX_EXPERIMENTAL_CXX0X__
216 template<typename _IIter, typename _OIter, typename _Predicate>
217 _OIter
218 copy_if(_IIter, _IIter, _OIter, _Predicate);
220 template<typename _IIter, typename _Size, typename _OIter>
221 _OIter
222 copy_n(_IIter, _Size, _OIter);
223 #endif
225 // count
226 // count_if
228 template<typename _FIter, typename _Tp>
229 pair<_FIter, _FIter>
230 equal_range(_FIter, _FIter, const _Tp&);
232 template<typename _FIter, typename _Tp, typename _Compare>
233 pair<_FIter, _FIter>
234 equal_range(_FIter, _FIter, const _Tp&, _Compare);
236 template<typename _FIter, typename _Tp>
237 void
238 fill(_FIter, _FIter, const _Tp&);
240 template<typename _OIter, typename _Size, typename _Tp>
241 _OIter
242 fill_n(_OIter, _Size, const _Tp&);
244 // find
246 template<typename _FIter1, typename _FIter2>
247 _FIter1
248 find_end(_FIter1, _FIter1, _FIter2, _FIter2);
250 template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
251 _FIter1
252 find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
254 // find_first_of
255 // find_if
257 #ifdef __GXX_EXPERIMENTAL_CXX0X__
258 template<typename _IIter, typename _Predicate>
259 _IIter
260 find_if_not(_IIter, _IIter, _Predicate);
261 #endif
263 // for_each
264 // generate
265 // generate_n
267 template<typename _IIter1, typename _IIter2>
268 bool
269 includes(_IIter1, _IIter1, _IIter2, _IIter2);
271 template<typename _IIter1, typename _IIter2, typename _Compare>
272 bool
273 includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
275 template<typename _BIter>
276 void
277 inplace_merge(_BIter, _BIter, _BIter);
279 template<typename _BIter, typename _Compare>
280 void
281 inplace_merge(_BIter, _BIter, _BIter, _Compare);
283 #ifdef __GXX_EXPERIMENTAL_CXX0X__
284 template<typename _RAIter>
285 bool
286 is_heap(_RAIter, _RAIter);
288 template<typename _RAIter, typename _Compare>
289 bool
290 is_heap(_RAIter, _RAIter, _Compare);
292 template<typename _RAIter>
293 _RAIter
294 is_heap_until(_RAIter, _RAIter);
296 template<typename _RAIter, typename _Compare>
297 _RAIter
298 is_heap_until(_RAIter, _RAIter, _Compare);
300 template<typename _IIter, typename _Predicate>
301 bool
302 is_partitioned(_IIter, _IIter, _Predicate);
304 template<typename _FIter>
305 bool
306 is_sorted(_FIter, _FIter);
308 template<typename _FIter, typename _Compare>
309 bool
310 is_sorted(_FIter, _FIter, _Compare);
312 template<typename _FIter>
313 _FIter
314 is_sorted_until(_FIter, _FIter);
316 template<typename _FIter, typename _Compare>
317 _FIter
318 is_sorted_until(_FIter, _FIter, _Compare);
319 #endif
321 template<typename _FIter1, typename _FIter2>
322 void
323 iter_swap(_FIter1, _FIter2);
325 template<typename _FIter, typename _Tp>
326 _FIter
327 lower_bound(_FIter, _FIter, const _Tp&);
329 template<typename _FIter, typename _Tp, typename _Compare>
330 _FIter
331 lower_bound(_FIter, _FIter, const _Tp&, _Compare);
333 template<typename _RAIter>
334 void
335 make_heap(_RAIter, _RAIter);
337 template<typename _RAIter, typename _Compare>
338 void
339 make_heap(_RAIter, _RAIter, _Compare);
341 template<typename _Tp>
342 const _Tp&
343 max(const _Tp&, const _Tp&);
345 template<typename _Tp, typename _Compare>
346 const _Tp&
347 max(const _Tp&, const _Tp&, _Compare);
349 // max_element
350 // merge
352 template<typename _Tp>
353 const _Tp&
354 min(const _Tp&, const _Tp&);
356 template<typename _Tp, typename _Compare>
357 const _Tp&
358 min(const _Tp&, const _Tp&, _Compare);
360 // min_element
362 #ifdef __GXX_EXPERIMENTAL_CXX0X__
363 template<typename _Tp>
364 pair<const _Tp&, const _Tp&>
365 minmax(const _Tp&, const _Tp&);
367 template<typename _Tp, typename _Compare>
368 pair<const _Tp&, const _Tp&>
369 minmax(const _Tp&, const _Tp&, _Compare);
371 template<typename _FIter>
372 pair<_FIter, _FIter>
373 minmax_element(_FIter, _FIter);
375 template<typename _FIter, typename _Compare>
376 pair<_FIter, _FIter>
377 minmax_element(_FIter, _FIter, _Compare);
379 template<typename _Tp>
381 min(initializer_list<_Tp>);
383 template<typename _Tp, typename _Compare>
385 min(initializer_list<_Tp>, _Compare);
387 template<typename _Tp>
389 max(initializer_list<_Tp>);
391 template<typename _Tp, typename _Compare>
393 max(initializer_list<_Tp>, _Compare);
395 template<typename _Tp>
396 pair<_Tp, _Tp>
397 minmax(initializer_list<_Tp>);
399 template<typename _Tp, typename _Compare>
400 pair<_Tp, _Tp>
401 minmax(initializer_list<_Tp>, _Compare);
402 #endif
404 // mismatch
406 template<typename _BIter>
407 bool
408 next_permutation(_BIter, _BIter);
410 template<typename _BIter, typename _Compare>
411 bool
412 next_permutation(_BIter, _BIter, _Compare);
414 #ifdef __GXX_EXPERIMENTAL_CXX0X__
415 template<typename _IIter, typename _Predicate>
416 bool
417 none_of(_IIter, _IIter, _Predicate);
418 #endif
420 // nth_element
421 // partial_sort
423 template<typename _IIter, typename _RAIter>
424 _RAIter
425 partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter);
427 template<typename _IIter, typename _RAIter, typename _Compare>
428 _RAIter
429 partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare);
431 // partition
433 #ifdef __GXX_EXPERIMENTAL_CXX0X__
434 template<typename _IIter, typename _OIter1,
435 typename _OIter2, typename _Predicate>
436 pair<_OIter1, _OIter2>
437 partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate);
439 template<typename _FIter, typename _Predicate>
440 _FIter
441 partition_point(_FIter, _FIter, _Predicate);
442 #endif
444 template<typename _RAIter>
445 void
446 pop_heap(_RAIter, _RAIter);
448 template<typename _RAIter, typename _Compare>
449 void
450 pop_heap(_RAIter, _RAIter, _Compare);
452 template<typename _BIter>
453 bool
454 prev_permutation(_BIter, _BIter);
456 template<typename _BIter, typename _Compare>
457 bool
458 prev_permutation(_BIter, _BIter, _Compare);
460 template<typename _RAIter>
461 void
462 push_heap(_RAIter, _RAIter);
464 template<typename _RAIter, typename _Compare>
465 void
466 push_heap(_RAIter, _RAIter, _Compare);
468 // random_shuffle
470 template<typename _FIter, typename _Tp>
471 _FIter
472 remove(_FIter, _FIter, const _Tp&);
474 template<typename _FIter, typename _Predicate>
475 _FIter
476 remove_if(_FIter, _FIter, _Predicate);
478 template<typename _IIter, typename _OIter, typename _Tp>
479 _OIter
480 remove_copy(_IIter, _IIter, _OIter, const _Tp&);
482 template<typename _IIter, typename _OIter, typename _Predicate>
483 _OIter
484 remove_copy_if(_IIter, _IIter, _OIter, _Predicate);
486 // replace
488 template<typename _IIter, typename _OIter, typename _Tp>
489 _OIter
490 replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&);
492 template<typename _Iter, typename _OIter, typename _Predicate, typename _Tp>
493 _OIter
494 replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&);
496 // replace_if
498 template<typename _BIter>
499 void
500 reverse(_BIter, _BIter);
502 template<typename _BIter, typename _OIter>
503 _OIter
504 reverse_copy(_BIter, _BIter, _OIter);
506 template<typename _FIter>
507 void
508 rotate(_FIter, _FIter, _FIter);
510 template<typename _FIter, typename _OIter>
511 _OIter
512 rotate_copy(_FIter, _FIter, _FIter, _OIter);
514 // search
515 // search_n
516 // set_difference
517 // set_intersection
518 // set_symmetric_difference
519 // set_union
521 #if defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
522 template<typename _RAIter, typename _UGenerator>
523 void
524 shuffle(_RAIter, _RAIter, _UGenerator&&);
525 #endif
527 template<typename _RAIter>
528 void
529 sort_heap(_RAIter, _RAIter);
531 template<typename _RAIter, typename _Compare>
532 void
533 sort_heap(_RAIter, _RAIter, _Compare);
535 template<typename _BIter, typename _Predicate>
536 _BIter
537 stable_partition(_BIter, _BIter, _Predicate);
539 template<typename _Tp>
540 void
541 swap(_Tp&, _Tp&);
543 template<typename _Tp, size_t _Nm>
544 void
545 swap(_Tp (&)[_Nm], _Tp (&)[_Nm]);
547 template<typename _FIter1, typename _FIter2>
548 _FIter2
549 swap_ranges(_FIter1, _FIter1, _FIter2);
551 // transform
553 template<typename _FIter>
554 _FIter
555 unique(_FIter, _FIter);
557 template<typename _FIter, typename _BinaryPredicate>
558 _FIter
559 unique(_FIter, _FIter, _BinaryPredicate);
561 // unique_copy
563 template<typename _FIter, typename _Tp>
564 _FIter
565 upper_bound(_FIter, _FIter, const _Tp&);
567 template<typename _FIter, typename _Tp, typename _Compare>
568 _FIter
569 upper_bound(_FIter, _FIter, const _Tp&, _Compare);
571 _GLIBCXX_END_NAMESPACE
573 _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
575 template<typename _FIter>
576 _FIter
577 adjacent_find(_FIter, _FIter);
579 template<typename _FIter, typename _BinaryPredicate>
580 _FIter
581 adjacent_find(_FIter, _FIter, _BinaryPredicate);
583 template<typename _IIter, typename _Tp>
584 typename iterator_traits<_IIter>::difference_type
585 count(_IIter, _IIter, const _Tp&);
587 template<typename _IIter, typename _Predicate>
588 typename iterator_traits<_IIter>::difference_type
589 count_if(_IIter, _IIter, _Predicate);
591 template<typename _IIter1, typename _IIter2>
592 bool
593 equal(_IIter1, _IIter1, _IIter2);
595 template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
596 bool
597 equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate);
599 template<typename _IIter, typename _Tp>
600 _IIter
601 find(_IIter, _IIter, const _Tp&);
603 template<typename _FIter1, typename _FIter2>
604 _FIter1
605 find_first_of(_FIter1, _FIter1, _FIter2, _FIter2);
607 template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
608 _FIter1
609 find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
611 template<typename _IIter, typename _Predicate>
612 _IIter
613 find_if(_IIter, _IIter, _Predicate);
615 template<typename _IIter, typename _Funct>
616 _Funct
617 for_each(_IIter, _IIter, _Funct);
619 template<typename _FIter, typename _Generator>
620 void
621 generate(_FIter, _FIter, _Generator);
623 template<typename _OIter, typename _Size, typename _Generator>
624 _OIter
625 generate_n(_OIter, _Size, _Generator);
627 template<typename _IIter1, typename _IIter2>
628 bool
629 lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2);
631 template<typename _IIter1, typename _IIter2, typename _Compare>
632 bool
633 lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
635 template<typename _FIter>
636 _FIter
637 max_element(_FIter, _FIter);
639 template<typename _FIter, typename _Compare>
640 _FIter
641 max_element(_FIter, _FIter, _Compare);
643 template<typename _IIter1, typename _IIter2, typename _OIter>
644 _OIter
645 merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
647 template<typename _IIter1, typename _IIter2, typename _OIter,
648 typename _Compare>
649 _OIter
650 merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
652 template<typename _FIter>
653 _FIter
654 min_element(_FIter, _FIter);
656 template<typename _FIter, typename _Compare>
657 _FIter
658 min_element(_FIter, _FIter, _Compare);
660 template<typename _IIter1, typename _IIter2>
661 pair<_IIter1, _IIter2>
662 mismatch(_IIter1, _IIter1, _IIter2);
664 template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
665 pair<_IIter1, _IIter2>
666 mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate);
668 template<typename _RAIter>
669 void
670 nth_element(_RAIter, _RAIter, _RAIter);
672 template<typename _RAIter, typename _Compare>
673 void
674 nth_element(_RAIter, _RAIter, _RAIter, _Compare);
676 template<typename _RAIter>
677 void
678 partial_sort(_RAIter, _RAIter, _RAIter);
680 template<typename _RAIter, typename _Compare>
681 void
682 partial_sort(_RAIter, _RAIter, _RAIter, _Compare);
684 template<typename _BIter, typename _Predicate>
685 _BIter
686 partition(_BIter, _BIter, _Predicate);
688 template<typename _RAIter>
689 void
690 random_shuffle(_RAIter, _RAIter);
692 template<typename _RAIter, typename _Generator>
693 void
694 random_shuffle(_RAIter, _RAIter,
695 #ifdef __GXX_EXPERIMENTAL_CXX0X__
696 _Generator&&);
697 #else
698 _Generator&);
699 #endif
701 template<typename _FIter, typename _Tp>
702 void
703 replace(_FIter, _FIter, const _Tp&, const _Tp&);
705 template<typename _FIter, typename _Predicate, typename _Tp>
706 void
707 replace_if(_FIter, _FIter, _Predicate, const _Tp&);
709 template<typename _FIter1, typename _FIter2>
710 _FIter1
711 search(_FIter1, _FIter1, _FIter2, _FIter2);
713 template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
714 _FIter1
715 search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
717 template<typename _FIter, typename _Size, typename _Tp>
718 _FIter
719 search_n(_FIter, _FIter, _Size, const _Tp&);
721 template<typename _FIter, typename _Size, typename _Tp,
722 typename _BinaryPredicate>
723 _FIter
724 search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate);
726 template<typename _IIter1, typename _IIter2, typename _OIter>
727 _OIter
728 set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
730 template<typename _IIter1, typename _IIter2, typename _OIter,
731 typename _Compare>
732 _OIter
733 set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
735 template<typename _IIter1, typename _IIter2, typename _OIter>
736 _OIter
737 set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
739 template<typename _IIter1, typename _IIter2, typename _OIter,
740 typename _Compare>
741 _OIter
742 set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
744 template<typename _IIter1, typename _IIter2, typename _OIter>
745 _OIter
746 set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
748 template<typename _IIter1, typename _IIter2, typename _OIter,
749 typename _Compare>
750 _OIter
751 set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2,
752 _OIter, _Compare);
754 template<typename _IIter1, typename _IIter2, typename _OIter>
755 _OIter
756 set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
758 template<typename _IIter1, typename _IIter2, typename _OIter,
759 typename _Compare>
760 _OIter
761 set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
763 template<typename _RAIter>
764 void
765 sort(_RAIter, _RAIter);
767 template<typename _RAIter, typename _Compare>
768 void
769 sort(_RAIter, _RAIter, _Compare);
771 template<typename _RAIter>
772 void
773 stable_sort(_RAIter, _RAIter);
775 template<typename _RAIter, typename _Compare>
776 void
777 stable_sort(_RAIter, _RAIter, _Compare);
779 template<typename _IIter, typename _OIter, typename _UnaryOperation>
780 _OIter
781 transform(_IIter, _IIter, _OIter, _UnaryOperation);
783 template<typename _IIter1, typename _IIter2, typename _OIter,
784 typename _BinaryOperation>
785 _OIter
786 transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation);
788 template<typename _IIter, typename _OIter>
789 _OIter
790 unique_copy(_IIter, _IIter, _OIter);
792 template<typename _IIter, typename _OIter, typename _BinaryPredicate>
793 _OIter
794 unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate);
796 _GLIBCXX_END_NESTED_NAMESPACE
798 #ifdef _GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL
799 # include <parallel/algorithmfwd.h>
800 #endif
802 #endif