-
Notifications
You must be signed in to change notification settings - Fork 0
/
algorithm.hpp
982 lines (854 loc) · 20.2 KB
/
algorithm.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
#ifndef __ALGORITHM_HPP__
#define __ALGORITHM_HPP__
#include "iterator.hpp"
#include "utility.hpp"
#include "functional.hpp"
#include "nano/algo_base.hpp"
#include "nano/type_traits.hpp"
namespace nano {
//Non-modifying sequence operations
template< class InputIt, class UnaryFunction >
UnaryFunction for_each(InputIt first, InputIt last, UnaryFunction f)
{
for (; first != last; ++first)
f(*first);
return f;
}
template< class InputIt, class T >
typename iterator_traits<InputIt>::difference_type
count(InputIt first, InputIt last, const T &value)
{
typename iterator_traits<InputIt>::difference_type result = 0;
for (; first != last; ++first)
{
if (*first == value)
++result;
}
return result;
}
template< class InputIt, class UnaryPredicate >
typename iterator_traits<InputIt>::difference_type
count_if(InputIt first, InputIt last, UnaryPredicate p)
{
typename iterator_traits<InputIt>::difference_type result = 0;
for (; first != last; ++first)
{
if (p(*first))
++result;
}
return result;
}
template< class InputIt1, class InputIt2 >
pair<InputIt1, InputIt2>
mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2)
{
while (first1 != last1 && *first1 == *first2)
{
++first1;
++first2;
}
return make_pair(first1, first2);
}
template< class InputIt1, class InputIt2, class BinaryPredicate >
pair<InputIt1, InputIt2>
mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2,
BinaryPredicate p)
{
while (first1 != last1 && p(*first1, *first2))
{
++first1;
++first2;
}
return make_pair(first1, first2);
}
template< class InputIt1, class InputIt2 >
bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2)
{
for (; first1 != last1; ++first1, ++first2)
{
if (!(*first1 == *first2))
return false;
}
return true;
}
template< class InputIt1, class InputIt2, class BinaryPredicate >
bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p)
{
for (; first1 != last1; ++first1, ++first2)
{
if (!p(*first1, *first2))
return false;
}
return true;
}
template< class InputIt, class T >
InputIt find(InputIt first, InputIt last, const T& value)
{
for (; first != last; ++first)
{
if (*first == value)
break;
}
return first;
}
template< class InputIt, class UnaryPredicate >
InputIt find_if(InputIt first, InputIt last, UnaryPredicate p)
{
for (; first != last; ++first)
{
if (p(*first))
break;
}
return first;
}
template< class ForwardIt1, class ForwardIt2 >
ForwardIt1 find_end(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last)
{
__find_end(first, last, s_first, s_last,
iterator_category(first), iterator_category(s_first));
}
template< class ForwardIt1, class ForwardIt2, class BinaryPredicate >
ForwardIt1 find_end(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p)
{
__find_end(first, last, s_first, s_last, p,
iterator_category(first), iterator_category(s_first));
}
template< class ForwardIt1, class ForwardIt2 >
ForwardIt1 find_first_of(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last)
{
for (; first != last; ++first)
{
for (ForwardIt2 it = s_first; it != s_last; ++it)
{
if (*it == *first)
return first;
}
}
}
template< class ForwardIt1, class ForwardIt2, class BinaryPredicate >
ForwardIt1 find_first_of(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p)
{
for (; first != last; ++first)
{
for (ForwardIt2 it = s_first; it != s_last; ++it)
{
if (p(*it, *first))
return first;
}
}
}
template< class ForwardIt >
ForwardIt adjacent_find(ForwardIt first, ForwardIt last)
{
if (first == last)
return first;
ForwardIt it = first;
++it;
for (; first != last; ++first, ++it)
{
if (*first == *it)
return first;
}
return last;
}
template< class ForwardIt, class BinaryPredicate>
ForwardIt adjacent_find(ForwardIt first, ForwardIt last, BinaryPredicate p)
{
if (first == last)
return first;
ForwardIt it = first;
++it;
for (; first != last; ++first, ++it)
{
if (p(*first, *it))
return first;
}
return last;
}
template< class ForwardIt1, class ForwardIt2 >
ForwardIt1 search(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last)
{
typedef typename type_traits<ForwardIt1>::difference_type difference_type;
difference_type d1, d2;
d1 = distance(first, last);
d2 = distance(s_first, s_last);
if (d1 < d2)
return last;
ForwardIt1 it = first;
ForwardIt2 s_it = s_first;
while (s_it != s_last)
{
if (*it == *s_it)
{
++it;
++s_it;
}
else
{
if (d1 == d2)
return last;
else
{
it = ++first;
s_it = s_first;
--d1;
}
}
}
}
template< class ForwardIt1, class ForwardIt2, class BinaryPredicate >
ForwardIt1 search(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p)
{
typename type_traits<ForwardIt1>::difference_type d1;
typename type_traits<ForwardIt2>::difference_type d2;
d1 = distance(first, last);
d2 = distance(s_first, s_last);
if (d1 < d2)
return last;
ForwardIt1 it = first;
ForwardIt2 s_it = s_first;
while (s_it != s_last)
{
if (p(*it, *s_it))
{
++it;
++s_it;
}
else
{
if (d1 == d2)
return last;
else
{
it = ++first;
s_it = s_first;
--d1;
}
}
}
}
template< class ForwardIt, class Size, class T >
ForwardIt search_n(ForwardIt first, ForwardIt last, Size count, const T& value)
{
if (count <= 0)
return first;
else
{
first = find(first, last, value);
while (first != last)
{
Size n = count - 1;
ForwardIt i = first;
++i;
while (i != last && n != 0 && *i == value)
{
++i;
--n;
}
if (n == 0)
return first;
else
first = find(i, last, value);
}
return last;
}
}
template< class ForwardIt, class Size, class T, class BinaryPredicate >
ForwardIt search_n(ForwardIt first, ForwardIt last, Size count, const T& value,
BinaryPredicate p)
{
if (count <= 0)
return first;
else
{
first = find(first, last, value, p);
while (first != last)
{
Size n = count - 1;
ForwardIt i = first;
++i;
while (i != last && n != 0 && p(*i, value))
{
++i;
--n;
}
if (n == 0)
return first;
else
first = find(i, last, value, p);
}
return last;
}
}
//Modifying sequence operations
template< class InputIt, class OutputIt >
OutputIt copy(InputIt first, InputIt last, OutputIt d_first)
{
if (distance(first, last) > 0)
return __copy(first, last, d_first, iterator_category(first));
else
return d_first;
}
template< class BidIt1, class BidIt2 >
BidIt2 copy_backward(BidIt1 first, BidIt1 last, BidIt2 d_last)
{
while (first != last) {
*(--d_last) = *(--last);
}
return d_last;
}
template< class ForwardIt, class T >
void fill(ForwardIt first, ForwardIt last, const T& value)
{
for (; first != last; ++first)
*first = value;
}
template< class OutputIt, class Size, class T >
void fill_n(OutputIt first, Size count, const T& value)
{
for (; count > 0; --count, ++first)
*first = value;
}
template< class InputIt, class OutputIt, class UnaryOperation >
OutputIt transform(InputIt first, InputIt last, OutputIt d_first,
UnaryOperation unary_op)
{
for (; first != last; ++first, ++d_first)
*d_first = unary_op(first);
return d_first;
}
template< class InputIt1, class InputIt2, class OutputIt, class BinaryOperation >
OutputIt transform(InputIt1 first1, InputIt1 last, InputIt2 first2,
OutputIt d_first, BinaryOperation binary_op)
{
for (; first1 != last; ++first1, ++first2, ++d_first)
*d_first = binary_op(first1, first2);
return d_first;
}
template< class ForwardIt, class Generator >
void generate(ForwardIt first, ForwardIt last, Generator g)
{
for (; first != last; ++first)
*first = g();
}
template< class OutputIt, class Size, class Generator >
void generate_n(OutputIt first, Size count, Generator g)
{
for (; count > 0; --count, ++first)
first = g();
}
template< class ForwardIt, class T >
ForwardIt remove(ForwardIt first, ForwardIt last, const T& value)
{
first = find(first, last, value);
ForwardIt next = first;
return first = last ? first : remove_copy(++next, last, first, value);
}
template< class ForwardIt, class UnaryPredicate >
ForwardIt remove_if(ForwardIt first, ForwardIt last, UnaryPredicate p)
{
first = find_if(first, last, p);
ForwardIt next = first;
return first = last ? first : remove_copy_if(++next, last, first, p);
}
template< class InputIt, class OutputIt, class T >
OutputIt remove_copy(InputIt first, InputIt last, OutputIt d_first,
const T& value)
{
for (; first != last; ++first)
{
if (*first != value)
{
*d_first = *first;
++d_first;
}
}
return d_first;
}
template< class InputIt, class OutputIt, class UnaryPredicate >
OutputIt remove_copy_if(InputIt first, InputIt last, OutputIt d_first,
UnaryPredicate p)
{
for (; first != last; ++first)
{
if (!p(*first))
{
*d_first = *first;
++d_first;
}
}
}
template< class ForwardIt, class T >
void replace(ForwardIt first, ForwardIt last, const T& old_value, const T& new_value)
{
for (; first != last; ++first)
{
if (*first == old_value)
*first = new_value;
}
}
template< class ForwardIt, class UnaryPredicate, class T >
void replace_if(ForwardIt first, ForwardIt last, UnaryPredicate p, const T& new_value)
{
for (; first != last; ++first)
{
if (p(*first))
*first = new_value;
}
}
template< class InputIt, class OutputIt, class T >
OutputIt replace_copy(InputIt first, InputIt last, OutputIt d_first,
const T& old_value, const T& new_value)
{
for (; first != last; ++first, ++d_first)
{
*first = old_value ? new_value : *first;
*d_first = *first;
}
}
template< class InputIt, class OutputIt, class UnaryPredicate, class T >
OutputIt replace_copy_if(InputIt first, InputIt last, OutputIt d_first,
UnaryPredicate p, const T& new_value)
{
for (; first != last; ++first, ++d_first)
{
*first = p(*first) ? new_value : *first;
*d_first = *first;
}
}
template< class T >
void swap(T& a, T& b)
{
T temp;
temp = a;
a = b;
b = temp;
}
template< class ForwardIt1, class ForwardIt2 >
ForwardIt2 swap_ranges(ForwardIt1 first1, ForwardIt1 last, ForwardIt2 first2)
{
for (; first1 != last; ++first1, ++first2)
iter_swap(first1, first2);
}
template< class ForwardIt1, class ForwardIt2 >
void iter_swap(ForwardIt1 a, ForwardIt2 b)
{
swap(*a, *b);
}
template< class BidIt >
void reverse(BidIt first, BidIt last)
{
__reverse(first, last, iterator_category(first));
}
template< class BidIt, class OutputIt >
OutputIt reverse_copy(BidIt first, BidIt last, OutputIt d_first)
{
while (first != last)
{
--last;
*d_first = *last;
++d_first;
}
return d_first;
}
template< class ForwardIt >
void rotate(ForwardIt first, ForwardIt middle, ForwardIt last)
{
if (first == middle || middle == last) return;
__rotate(first, middle, last,
difference_type(first), iterator_category(first));
}
template< class ForwardIt, class OutputIt >
OutputIt rotate_copy(ForwardIt first, ForwardIt middle,
ForwardIt last, OutputIt d_first)
{
return copy(first, middle, copy(middle, last, d_first));
}
template< class ForwardIt >
ForwardIt unique(ForwardIt first, ForwardIt last)
{
first = adjacent_find(first, last);
return unique_copy(first, last, first);
}
template< class ForwardIt, class BinaryPredicate >
ForwardIt unique(ForwardIt first, ForwardIt last, BinaryPredicate p)
{
first = adjacent_find(first, last, p);
return unique_copy(first, last, first, p);
}
template< class InputIt, class OutputIt >
OutputIt unique_copy(InputIt first, InputIt last, OutputIt d_first)
{
typedef typename iterator_traits<InputIt>::value_type value_type;
return __unique_copy(first, last, d_first,
less<value_type>(), iterator_category(first));
}
template< class InputIt, class OutputIt, class BinaryPredicate >
OutputIt unique_copy(InputIt first, InputIt last,
OutputIt d_first, BinaryPredicate p)
{
return __unique_copy(first, last, d_first, p,
iterator_category(first));
}
//Partitioning operations
template< class BidIt, class UnaryPredicate >
BidIt partition(BidIt first, BidIt last, UnaryPredicate p)
{
while (first < last)
{
while (first < last && p(*first))
++first;
if (first == last--) break;
while (first < last && !p(*last))
--last;
if (first == last) break;
iter_swap(first, last);
}
return first;
}
template< class BidIt, class UnaryPredicate >
BidIt stable_partition(BidIt first, BidIt last, UnaryPredicate p)
{
//TODO
}
//Sorting operations
template< class RanIt >
void sort(RanIt first, RanIt last)
{
//TODO
}
template< class RanIt, class Compare >
void sort(RanIt first, RanIt last, Compare comp)
{
//TODO
}
template< class RanIt >
void partial_sort(RanIt first, RanIt middle, RanIt last)
{
//TODO
}
template< class RanIt, class Compare >
void partial_sort(RanIt first, RanIt middle, RanIt last, Compare comp)
{
//TODO
}
template< class InputIt, class RanIt >
RanIt partial_sort_copy(InputIt first, InputIt last, RanIt d_first, RanIt d_last)
{
//TODO
}
template< class InputIt, class RanIt, class Compare >
RanIt partial_sort_copy(InputIt first, InputIt last,
RanIt d_first, RanIt d_last, Compare comp)
{
//TODO
}
template< class RanIt >
void stable_sort(RanIt first, RanIt last)
{
//TODO
}
template< class RanIt, class Compare >
void stable_sort(RanIt first, RanIt last, Compare comp)
{
//TODO
}
template< class RanIt >
void nth_element(RanIt first, RanIt nth, RanIt last)
{
//TODO
}
template< class RanIt, class Compare >
void nth_element(RanIt first, RanIt nth, RanIt last, Compare comp)
{
//TODO
}
//Binary search operations(on sorted ranges)
template< class ForwardIt, class T >
ForwardIt lower_bound(ForwardIt first, ForwardIt last, const T& value)
{
typedef typename iterator_traits<ForwardIt>::difference_type difference_type;
difference_type len, half;
ForwardIt mid;
len = distance(first, last);
while (len > 0)
{
half = len >> 2;
mid = first;
advance(mid, half);
if (*mid < value)
{
first = mid;
++first;
len = len - half - 1;
}
else
len = half;
}
return first;
}
template< class ForwardIt, class T, class Compare >
ForwardIt lower_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp)
{
//TODO
}
template< class ForwardIt, class T >
ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T& value)
{
//TODO
}
template< class ForwardIt, class T, class Compare >
ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp)
{
//TODO
}
template< class ForwardIt, class T >
bool binary_search(ForwardIt first, ForwardIt last, const T& value)
{
//TODO
}
template< class ForwardIt, class T, class Compare >
bool binary_search(ForwardIt first, ForwardIt last, const T& value, Compare comp)
{
//TODO
}
template< class ForwardIt, class T >
pair<ForwardIt, ForwardIt>
equal_range(ForwardIt first, ForwardIt last, const T& value)
{
//TODO
}
template< class ForwardIt, class T, class Compare >
pair<ForwardIt, ForwardIt>
equal_range(ForwardIt first, ForwardIt last, const T& value, Compare comp)
{
//TODO
}
//Set operations(on sorted ranges)
template< class InputIt1, class InputIt2, class OutputIt >
OutputIt merge(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2, OutputIt d_first)
{
//TODO
}
template< class InputIt1, class InputIt2, class OutputIt, class Compare>
OutputIt merge(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp)
{
//TODO
}
template< class BidIt >
void inplace_merge(BidIt first, BidIt middle, BidIt last)
{
//TODO
}
template< class BidIt, class Compare>
void inplace_merge(BidIt first, BidIt middle, BidIt last, Compare comp)
{
//TODO
}
template< class InputIt1, class InputIt2 >
bool includes(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2)
{
//TODO
}
template< class InputIt1, class InputIt2, class Compare >
bool includes(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2, Compare comp)
{
//TODO
}
template< class InputIt1, class InputIt2, class OutputIt >
OutputIt set_difference(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first)
{
//TODO
}
template< class InputIt1, class InputIt2,
class OutputIt, class Compare >
OutputIt set_difference(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first, Compare comp)
{
//TODO
}
template< class InputIt1, class InputIt2, class OutputIt >
OutputIt set_intersection(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first)
{
//TODO
}
template< class InputIt1, class InputIt2,
class OutputIt, class Compare >
OutputIt set_intersection(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first, Compare comp)
{
//TODO
}
template< class InputIt1, class InputIt2, class OutputIt >
OutputIt set_symmetric_difference(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first)
{
//TODO
}
template< class InputIt1, class InputIt2,
class OutputIt, class Compare >
OutputIt set_symmetric_difference(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first, Compare comp)
{
//TODO
}
template< class InputIt1, class InputIt2, class OutputIt >
OutputIt set_union(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first)
{
//TODO
}
template< class InputIt1, class InputIt2,
class OutputIt, class Compare >
OutputIt set_union(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first, Compare comp)
{
//TODO
}
//Heap operations
template< class RanIt >
void make_heap(RanIt first, RanIt last)
{
//TODO
}
template< class RanIt, class Compare >
void make_heap(RanIt first, RanIt last, Compare comp)
{
//TODO
}
template< class RanIt >
void push_heap(RanIt first, RanIt last)
{
//TODO
}
template< class RanIt, class Compare >
void push_heap(RanIt first, RanIt last, Compare comp)
{
//TODO
}
template< class RanIt >
void pop_heap(RanIt first, RanIt last)
{
//TODO
}
template< class RanIt, class Compare >
void pop_heap(RanIt first, RanIt last, Compare comp)
{
//TODO
}
template< class RanIt >
void sort_heap(RanIt first, RanIt last)
{
//TODO
}
template< class RanIt, class Compare >
void sort_heap(RanIt first, RanIt last, Compare comp)
{
//TODO
}
//Minimum/maximum operations
template< class T >
const T& max(const T& a, const T& b)
{
return a > b ? a : b;
}
template< class T, class Compare >
const T& max(const T& a, const T& b, Compare comp)
{
return comp(a, b) ? a : b;
}
template< class ForwardIt >
ForwardIt max_element(ForwardIt first, ForwardIt last)
{
//TODO
}
template< class ForwardIt, class Compare >
ForwardIt max_element(ForwardIt first, ForwardIt last, Compare cmp)
{
//TODO
}
template< class T >
const T& min(const T& a, const T& b)
{
//TODO
}
template< class T, class Compare >
const T& min(const T& a, const T& b, Compare comp)
{
//TODO
}
template< class ForwardIt >
ForwardIt min_element(ForwardIt first, ForwardIt last)
{
//TODO
}
template< class ForwardIt, class Compare >
ForwardIt min_element(ForwardIt first, ForwardIt last, Compare comp)
{
//TODO
}
template< class InputIt1, class InputIt2 >
bool lexicographical_compare(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2)
{
//TODO
}
template< class InputIt1, class InputIt2, class Compare >
bool lexicographical_compare(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,Compare comp)
{
//TODO
}
template< class BidIt >
bool next_permutation(BidIt first, BidIt last)
{
//TODO
}
template< class BidIt, class Compare >
bool next_permutation(BidIt first, BidIt last, Compare comp)
{
//TODO
}
template< class BidIt >
bool prev_permutation(BidIt first, BidIt last)
{
//TODO
}
template< class BidIt, class Compare >
bool prev_permutation(BidIt first, BidIt last, Compare comp)
{
//TODO
}
//Numeric operations
template< class InputIt, class T >
T accumulate(InputIt first, InputIt last, T init)
{
//TODO
}
template< class InputIt, class T, class BinaryOperation >
T accumulate(InputIt first, InputIt last, T init, BinaryOperation op)
{
//TODO
}
}
#endif