\hypertarget{algorithm_8cpp_source}{}\doxysection{algorithm.\+cpp} \label{algorithm_8cpp_source}\index{tests/algorithm.cpp@{tests/algorithm.cpp}} \mbox{\hyperlink{algorithm_8cpp}{Go to the documentation of this file.}} \begin{DoxyCode}{0} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00001}00001 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{algorithm_8h}{kblib/algorithm.h}}"{}}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00002}00002 \textcolor{preprocessor}{\#include "{}catch.hpp"{}}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00003}00003 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00004}00004 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00005}00005 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00006}00006 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00007}00007 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00008}00008 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00009}\mbox{\hyperlink{algorithm_8cpp_ac637be6eb28e3385a0eec3896b522c7a}{00009}} \mbox{\hyperlink{algorithm_8cpp_ac637be6eb28e3385a0eec3896b522c7a}{TEST\_CASE}}(\textcolor{stringliteral}{"{}erase"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00010}00010 \textcolor{keyword}{const} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{equal}} = [](\textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}, \textcolor{keyword}{auto} b) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00011}00011 \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{std::equal}}(std::begin(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}), std::end(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}), std::begin(b), std::end(b));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00012}00012 \};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00013}00013 SECTION(\textcolor{stringliteral}{"{}erase and erase\_if"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00014}00014 \textcolor{keyword}{const} std::vector erase\_test\{2, 2, 3, 4, 5, 7, 8, 11\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00015}00015 \textcolor{keyword}{const} std::vector no\_2s = \{3, 4, 5, 7, 8, 11\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00016}00016 \textcolor{keyword}{auto} erase\_copy = erase\_test;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00017}00017 \mbox{\hyperlink{namespacekblib_aa760b40ea7f60976c66be6d77345317b}{kblib::erase}}(erase\_copy, 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00018}00018 CHECK(\mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{equal}}(no\_2s, erase\_copy));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00019}00019 erase\_copy = erase\_test;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00020}00020 \textcolor{keyword}{const} std::vector no\_evens = \{3, 5, 7, 11\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00021}00021 \mbox{\hyperlink{namespacekblib_aa1240cf764c5182f37ab5b5051f90b40}{kblib::erase\_if}}(erase\_copy, [](\textcolor{keywordtype}{unsigned} x) \{ \textcolor{keywordflow}{return} (\string~x) \& 1u; \});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00022}00022 CHECK(\mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{equal}}(no\_evens, erase\_copy));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00023}00023 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00024}00024 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00025}00025 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00026}\mbox{\hyperlink{algorithm_8cpp_aee44027e708f599ee110b381078d355e}{00026}} \mbox{\hyperlink{algorithm_8cpp_ac637be6eb28e3385a0eec3896b522c7a}{TEST\_CASE}}(\textcolor{stringliteral}{"{}find family"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00027}00027 \textcolor{comment}{// 0 1 2 3 4 5 6 7 8 9 e}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00028}00028 \textcolor{keywordtype}{int} vec[] = \{0, 3, 4, 5, 6, 1, 2, 4, 4, 5\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00029}00029 \textcolor{keyword}{auto} begin = std::begin(vec);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00030}00030 \textcolor{keyword}{auto} end = std::end(vec);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00031}00031 CHECK(\mbox{\hyperlink{namespacekblib_abc7f2ec97efdee8640fe38e73fe1fdad}{kblib::find}}(begin, end, 4) == begin + 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00032}00032 CHECK(\mbox{\hyperlink{namespacekblib_abc7f2ec97efdee8640fe38e73fe1fdad}{kblib::find}}(begin, end, 10) == end);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00033}00033 CHECK(\mbox{\hyperlink{namespacekblib_abc7f2ec97efdee8640fe38e73fe1fdad}{kblib::find}}(begin, end, 0) == begin);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00034}00034 CHECK(\mbox{\hyperlink{namespacekblib_abc7f2ec97efdee8640fe38e73fe1fdad}{kblib::find}}(begin, end, 10) == end);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00035}00035 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00036}00036 CHECK(\mbox{\hyperlink{namespacekblib_a985430339c0a2e1100d0c77faa47806f}{kblib::find\_last}}(begin, end, 10) == end);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00037}00037 CHECK(\mbox{\hyperlink{namespacekblib_a985430339c0a2e1100d0c77faa47806f}{kblib::find\_last}}(begin, end, 0) == begin);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00038}00038 CHECK(\mbox{\hyperlink{namespacekblib_a985430339c0a2e1100d0c77faa47806f}{kblib::find\_last}}(begin, end, 4) == begin + 8);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00039}00039 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00040}00040 CHECK(\mbox{\hyperlink{namespacekblib_a4b49eacc73a9295677cb08d9b7892ff6}{kblib::find\_if}}(begin, end, [](\textcolor{keywordtype}{int} i) \{ \textcolor{keywordflow}{return} i == 2; \}) == begin + 6);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00041}00041 CHECK(\mbox{\hyperlink{namespacekblib_ac30ce90c5b10639c0243952248897b51}{kblib::find\_if\_not}}(begin, end, [](\textcolor{keywordtype}{int} i) \{ \textcolor{keywordflow}{return} i == 2; \}) == begin);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00042}00042 CHECK(\mbox{\hyperlink{namespacekblib_a4b49eacc73a9295677cb08d9b7892ff6}{kblib::find\_if}}(begin, end, [](\textcolor{keywordtype}{int}) \{ \textcolor{keywordflow}{return} \textcolor{keyword}{false}; \}) == end);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00043}00043 CHECK(\mbox{\hyperlink{namespacekblib_ac30ce90c5b10639c0243952248897b51}{kblib::find\_if\_not}}(begin, end, [](\textcolor{keywordtype}{int}) \{ \textcolor{keywordflow}{return} \textcolor{keyword}{true}; \}) == end);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00044}00044 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00045}00045 CHECK(\mbox{\hyperlink{namespacekblib_afdfe60b4f1096a9f60d07cdfb4b5e427}{kblib::find\_last\_if}}(begin, end, [](\textcolor{keywordtype}{int} i) \{ \textcolor{keywordflow}{return} i == 2; \})} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00046}00046 == begin + 6);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00047}00047 CHECK(\mbox{\hyperlink{namespacekblib_a1782641d7170a2ef57145e460fe059be}{kblib::find\_last\_if\_not}}(begin, end, [](\textcolor{keywordtype}{int} i) \{ \textcolor{keywordflow}{return} i == 2; \})} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00048}00048 == begin + 9);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00049}00049 CHECK(\mbox{\hyperlink{namespacekblib_afdfe60b4f1096a9f60d07cdfb4b5e427}{kblib::find\_last\_if}}(begin, end, [](\textcolor{keywordtype}{int}) \{ \textcolor{keywordflow}{return} \textcolor{keyword}{false}; \}) == end);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00050}00050 CHECK(\mbox{\hyperlink{namespacekblib_a1782641d7170a2ef57145e460fe059be}{kblib::find\_last\_if\_not}}(begin, end, [](\textcolor{keywordtype}{int}) \{ \textcolor{keywordflow}{return} \textcolor{keyword}{true}; \}) == end);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00051}00051 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00052}00052 CHECK(\mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, 0));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00053}00053 CHECK(\mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, 1));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00054}00054 CHECK(\mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, 2));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00055}00055 CHECK(\mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, 3));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00056}00056 CHECK(\mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, 4));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00057}00057 CHECK(\mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, 5));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00058}00058 CHECK(\mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, 6));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00059}00059 CHECK(not \mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, 7));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00060}00060 CHECK(not \mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, 8));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00061}00061 CHECK(not \mbox{\hyperlink{namespacekblib_a049d0a38a218a1d7cf786ea8f01f2073}{kblib::contains}}(vec, -\/1));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00062}00062 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00063}00063 CHECK(\mbox{\hyperlink{namespacekblib_a906cc73872a93e33b3ce8a3a66319012}{kblib::contains\_any}}(vec, vec));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00064}00064 \textcolor{keywordtype}{int} none[] = \{7, 8, -\/1\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00065}00065 CHECK(not \mbox{\hyperlink{namespacekblib_a906cc73872a93e33b3ce8a3a66319012}{kblib::contains\_any}}(vec, none));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00066}00066 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00067}\mbox{\hyperlink{algorithm_8cpp_a2dbf50ac529c9e51c1a6131e091ebee2}{00067}} \mbox{\hyperlink{algorithm_8cpp_ac637be6eb28e3385a0eec3896b522c7a}{TEST\_CASE}}(\textcolor{stringliteral}{"{}find\_in"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00068}00068 \textcolor{comment}{// 0 1 2 3 4 5 6 7 8 9 e}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00069}00069 \textcolor{keywordtype}{int} vec[] = \{0, 3, 4, 5, 6, 1, 2, 4, 4, 5\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00070}00070 \textcolor{keyword}{auto} begin = std::begin(vec);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00071}00071 \textcolor{keyword}{auto} end = std::end(vec);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00072}00072 \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}} = \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{kblib::fakestd::size}}(vec);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00073}00073 CHECK(\mbox{\hyperlink{namespacekblib_a6cc206fcdb4a68b8cb6e393b5039a575}{kblib::find\_in}}(begin, end, 4) == 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00074}00074 CHECK(\mbox{\hyperlink{namespacekblib_a6cc206fcdb4a68b8cb6e393b5039a575}{kblib::find\_in}}(begin, end, 10) == \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00075}00075 CHECK(\mbox{\hyperlink{namespacekblib_a6cc206fcdb4a68b8cb6e393b5039a575}{kblib::find\_in}}(begin, end, 0) == 0);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00076}00076 CHECK(\mbox{\hyperlink{namespacekblib_a6cc206fcdb4a68b8cb6e393b5039a575}{kblib::find\_in}}(begin, end, 10) == \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00077}00077 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00078}00078 CHECK(\mbox{\hyperlink{namespacekblib_add03c5bc4490749865e16dff9030aa24}{kblib::find\_last\_in}}(begin, end, 10) == \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00079}00079 CHECK(\mbox{\hyperlink{namespacekblib_add03c5bc4490749865e16dff9030aa24}{kblib::find\_last\_in}}(begin, end, 0) == 0);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00080}00080 CHECK(\mbox{\hyperlink{namespacekblib_add03c5bc4490749865e16dff9030aa24}{kblib::find\_last\_in}}(begin, end, 4) == 8);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00081}00081 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00082}00082 CHECK(\mbox{\hyperlink{namespacekblib_ae565c2bd3542ecc900319508c4204a0d}{kblib::find\_in\_if}}(begin, end, [](\textcolor{keywordtype}{int} i) \{ \textcolor{keywordflow}{return} i == 2; \}) == 6);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00083}00083 CHECK(\mbox{\hyperlink{namespacekblib_a104b402a896c7ba42eeb1ba513961cb6}{kblib::find\_in\_if\_not}}(begin, end, [](\textcolor{keywordtype}{int} i) \{ \textcolor{keywordflow}{return} i == 2; \}) == 0);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00084}00084 CHECK(\mbox{\hyperlink{namespacekblib_ae565c2bd3542ecc900319508c4204a0d}{kblib::find\_in\_if}}(begin, end, [](\textcolor{keywordtype}{int}) \{ \textcolor{keywordflow}{return} \textcolor{keyword}{false}; \}) == \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00085}00085 CHECK(\mbox{\hyperlink{namespacekblib_a104b402a896c7ba42eeb1ba513961cb6}{kblib::find\_in\_if\_not}}(begin, end, [](\textcolor{keywordtype}{int}) \{ \textcolor{keywordflow}{return} \textcolor{keyword}{true}; \}) == \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00086}00086 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00087}00087 CHECK(\mbox{\hyperlink{namespacekblib_a45b776be68227a2b794c1345a3101df7}{kblib::find\_last\_in\_if}}(begin, end, [](\textcolor{keywordtype}{int} i) \{ \textcolor{keywordflow}{return} i == 2; \}) == 6);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00088}00088 CHECK(\mbox{\hyperlink{namespacekblib_a9b56a7bab2714ec861e909a930030cb6}{kblib::find\_last\_in\_if\_not}}(begin, end, [](\textcolor{keywordtype}{int} i) \{ \textcolor{keywordflow}{return} i == 2; \})} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00089}00089 == 9);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00090}00090 CHECK(\mbox{\hyperlink{namespacekblib_a45b776be68227a2b794c1345a3101df7}{kblib::find\_last\_in\_if}}(begin, end, [](\textcolor{keywordtype}{int}) \{ \textcolor{keywordflow}{return} \textcolor{keyword}{false}; \}) == \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00091}00091 CHECK(\mbox{\hyperlink{namespacekblib_a9b56a7bab2714ec861e909a930030cb6}{kblib::find\_last\_in\_if\_not}}(begin, end, [](\textcolor{keywordtype}{int}) \{ \textcolor{keywordflow}{return} \textcolor{keyword}{true}; \})} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00092}00092 == \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00093}00093 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00094}00094 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00095}\mbox{\hyperlink{algorithm_8cpp_a6e75297e2148be8c68ef99ca7385bee3}{00095}} \mbox{\hyperlink{algorithm_8cpp_ac637be6eb28e3385a0eec3896b522c7a}{TEST\_CASE}}(\textcolor{stringliteral}{"{}search\_replace"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00096}00096 \textcolor{keyword}{using namespace }std::literals;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00097}00097 \textcolor{keyword}{using }std::begin;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00098}00098 \textcolor{keyword}{using }std::end;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00099}00099 SECTION(\textcolor{stringliteral}{"{}search\_replace\_copy\_1"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00100}00100 \textcolor{keyword}{const} \textcolor{keyword}{auto} haystack = \textcolor{stringliteral}{"{}a string with words"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00101}00101 \textcolor{keyword}{const} \textcolor{keyword}{auto} needle = \textcolor{stringliteral}{"{}with"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00102}00102 \textcolor{keyword}{const} \textcolor{keyword}{auto} replace = \textcolor{stringliteral}{"{}comprising"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00103}00103 std::string result;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00104}00104 \mbox{\hyperlink{namespacekblib_ac237e40dd9be6a60c18b9b520b51e111}{kblib::search\_replace\_copy}}(begin(haystack), end(haystack), begin(needle),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00105}00105 end(needle), begin(replace), end(replace),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00106}00106 std::back\_inserter(result));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00107}00107 CHECK(result == \textcolor{stringliteral}{"{}a string comprising words"{}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00108}00108 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00109}00109 SECTION(\textcolor{stringliteral}{"{}search\_replace\_copy\_2(no match)"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00110}00110 \textcolor{keyword}{const} \textcolor{keyword}{auto} haystack = \textcolor{stringliteral}{"{}a string with words"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00111}00111 \textcolor{keyword}{const} \textcolor{keyword}{auto} needle = \textcolor{stringliteral}{"{}without"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00112}00112 \textcolor{keyword}{const} \textcolor{keyword}{auto} replace = \textcolor{stringliteral}{"{}comprising"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00113}00113 std::string result;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00114}00114 \mbox{\hyperlink{namespacekblib_ac237e40dd9be6a60c18b9b520b51e111}{kblib::search\_replace\_copy}}(begin(haystack), end(haystack), begin(needle),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00115}00115 end(needle), begin(replace), end(replace),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00116}00116 std::back\_inserter(result));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00117}00117 CHECK(result == haystack);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00118}00118 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00119}00119 SECTION(\textcolor{stringliteral}{"{}search\_replace\_copy\_3(multiple matches)"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00120}00120 \textcolor{keyword}{const} \textcolor{keyword}{auto} haystack = \textcolor{stringliteral}{"{}a string with multiple 'with's"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00121}00121 \textcolor{keyword}{const} \textcolor{keyword}{auto} needle = \textcolor{stringliteral}{"{}with"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00122}00122 \textcolor{keyword}{const} \textcolor{keyword}{auto} replace = \textcolor{stringliteral}{"{}containing"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00123}00123 std::string result;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00124}00124 \mbox{\hyperlink{namespacekblib_ac237e40dd9be6a60c18b9b520b51e111}{kblib::search\_replace\_copy}}(begin(haystack), end(haystack), begin(needle),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00125}00125 end(needle), begin(replace), end(replace),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00126}00126 std::back\_inserter(result));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00127}00127 CHECK(result == \textcolor{stringliteral}{"{}a string containing multiple 'containing's"{}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00128}00128 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00129}00129 SECTION(\textcolor{stringliteral}{"{}search\_replace\_copy\_4(empty match)"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00130}00130 \textcolor{keyword}{const} \textcolor{keyword}{auto} haystack = \textcolor{stringliteral}{"{}a string with words"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00131}00131 \textcolor{keyword}{const} \textcolor{keyword}{auto} needle = \textcolor{stringliteral}{"{}"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00132}00132 \textcolor{keyword}{const} \textcolor{keyword}{auto} replace = \textcolor{stringliteral}{"{}comprising"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00133}00133 std::string result;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00134}00134 \mbox{\hyperlink{namespacekblib_ac237e40dd9be6a60c18b9b520b51e111}{kblib::search\_replace\_copy}}(begin(haystack), end(haystack), begin(needle),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00135}00135 end(needle), begin(replace), end(replace),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00136}00136 std::back\_inserter(result));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00137}00137 CHECK(result == haystack);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00138}00138 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00139}00139 SECTION(\textcolor{stringliteral}{"{}search\_replace\_copy\_5(match at beginning)"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00140}00140 \textcolor{keyword}{const} \textcolor{keyword}{auto} haystack = \textcolor{stringliteral}{"{}a string with words"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00141}00141 \textcolor{keyword}{const} \textcolor{keyword}{auto} needle = \textcolor{stringliteral}{"{}a"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00142}00142 \textcolor{keyword}{const} \textcolor{keyword}{auto} replace = \textcolor{stringliteral}{"{}another"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00143}00143 std::string result;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00144}00144 \mbox{\hyperlink{namespacekblib_ac237e40dd9be6a60c18b9b520b51e111}{kblib::search\_replace\_copy}}(begin(haystack), end(haystack), begin(needle),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00145}00145 end(needle), begin(replace), end(replace),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00146}00146 std::back\_inserter(result));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00147}00147 CHECK(result == \textcolor{stringliteral}{"{}another string with words"{}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00148}00148 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00149}00149 SECTION(\textcolor{stringliteral}{"{}search\_replace\_copy\_6(match at end)"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00150}00150 \textcolor{keyword}{const} \textcolor{keyword}{auto} haystack = \textcolor{stringliteral}{"{}a string with words"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00151}00151 \textcolor{keyword}{const} \textcolor{keyword}{auto} needle = \textcolor{stringliteral}{"{}words"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00152}00152 \textcolor{keyword}{const} \textcolor{keyword}{auto} replace = \textcolor{stringliteral}{"{}letters"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00153}00153 std::string result;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00154}00154 \mbox{\hyperlink{namespacekblib_ac237e40dd9be6a60c18b9b520b51e111}{kblib::search\_replace\_copy}}(begin(haystack), end(haystack), begin(needle),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00155}00155 end(needle), begin(replace), end(replace),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00156}00156 std::back\_inserter(result));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00157}00157 CHECK(result == \textcolor{stringliteral}{"{}a string with letters"{}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00158}00158 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00159}00159 SECTION(\textcolor{stringliteral}{"{}search\_replace\_copy\_7(only matches)"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00160}00160 \textcolor{keyword}{const} \textcolor{keyword}{auto} haystack = \textcolor{stringliteral}{"{}abababababab"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00161}00161 \textcolor{keyword}{const} \textcolor{keyword}{auto} needle = \textcolor{stringliteral}{"{}ab"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00162}00162 \textcolor{keyword}{const} \textcolor{keyword}{auto} replace = \textcolor{stringliteral}{"{}ba"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00163}00163 std::string result;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00164}00164 \mbox{\hyperlink{namespacekblib_ac237e40dd9be6a60c18b9b520b51e111}{kblib::search\_replace\_copy}}(begin(haystack), end(haystack), begin(needle),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00165}00165 end(needle), begin(replace), end(replace),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00166}00166 std::back\_inserter(result));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00167}00167 CHECK(result == \textcolor{stringliteral}{"{}babababababa"{}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00168}00168 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00169}00169 SECTION(\textcolor{stringliteral}{"{}search\_replace\_copy\_8(match is whole string)"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00170}00170 \textcolor{keyword}{const} \textcolor{keyword}{auto} haystack = \textcolor{stringliteral}{"{}string"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00171}00171 \textcolor{keyword}{const} \textcolor{keyword}{auto}\& needle = haystack;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00172}00172 \textcolor{keyword}{const} \textcolor{keyword}{auto} replace = \textcolor{stringliteral}{"{}replace"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00173}00173 std::string result;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00174}00174 \mbox{\hyperlink{namespacekblib_ac237e40dd9be6a60c18b9b520b51e111}{kblib::search\_replace\_copy}}(begin(haystack), end(haystack), begin(needle),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00175}00175 end(needle), begin(replace), end(replace),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00176}00176 std::back\_inserter(result));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00177}00177 CHECK(result == replace);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00178}00178 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00179}00179 SECTION(\textcolor{stringliteral}{"{}search\_replace\_copy\_9(overlap)"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00180}00180 \textcolor{keyword}{const} \textcolor{keyword}{auto} haystack = \textcolor{stringliteral}{"{}abcabcab"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00181}00181 \textcolor{keyword}{const} \textcolor{keyword}{auto} needle = \textcolor{stringliteral}{"{}abcab"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00182}00182 \textcolor{keyword}{const} \textcolor{keyword}{auto} replace = \textcolor{stringliteral}{"{}a"{}}s;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00183}00183 std::string result;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00184}00184 \mbox{\hyperlink{namespacekblib_ac237e40dd9be6a60c18b9b520b51e111}{kblib::search\_replace\_copy}}(begin(haystack), end(haystack), begin(needle),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00185}00185 end(needle), begin(replace), end(replace),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00186}00186 std::back\_inserter(result));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00187}00187 CHECK(result == \textcolor{stringliteral}{"{}acab"{}});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00188}00188 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00189}00189 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00190}00190 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00191}\mbox{\hyperlink{algorithm_8cpp_a76f8ee15512dfae4b9e6f75c599f401a}{00191}} \mbox{\hyperlink{algorithm_8cpp_ac637be6eb28e3385a0eec3896b522c7a}{TEST\_CASE}}(\textcolor{stringliteral}{"{}get\_max family"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00193}00193 std::array arr\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00194}00194 \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00195}00195 \textcolor{keyword}{auto} max\_two} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00196}00196 = kblib::get\_max\_n\_old>(arr.begin(), arr.end(), 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00197}00197 CHECK(max\_two.size() == 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00198}00198 CHECK(\mbox{\hyperlink{namespacekblib_1_1nums_a64067ecc4167ce1cfe32860ef5c1dc47}{std::max}}(max\_two[0], max\_two[1]) == 10);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00199}00199 CHECK(\mbox{\hyperlink{namespacekblib_1_1nums_a24555c4b07301e176bf192adf4e80499}{std::min}}(max\_two[0], max\_two[1]) == 9);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00200}00200 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00201}00201 \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00202}00202 \textcolor{keyword}{auto} max\_two} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00203}00203 = kblib::get\_max\_n\_old>(arr.begin(), arr.end(), 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00204}00204 CHECK(max\_two.size() == 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00205}00205 CHECK(max\_two.find(10) != max\_two.end());} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00206}00206 CHECK(max\_two.find(9) != max\_two.end());} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00207}00207 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00208}00208 \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00209}00209 \textcolor{keyword}{auto} max\_two} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00210}00210 = kblib::get\_max\_n>(arr.begin(), arr.end(), 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00211}00211 CHECK(max\_two.size() == 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00212}00212 CHECK(\mbox{\hyperlink{namespacekblib_1_1nums_a64067ecc4167ce1cfe32860ef5c1dc47}{std::max}}(max\_two[0], max\_two[1]) == 10);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00213}00213 CHECK(\mbox{\hyperlink{namespacekblib_1_1nums_a24555c4b07301e176bf192adf4e80499}{std::min}}(max\_two[0], max\_two[1]) == 9);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00214}00214 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00215}00215 \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00216}00216 \textcolor{keyword}{auto} max\_two = kblib::get\_max\_n>(arr.begin(), arr.end(), 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00217}00217 CHECK(max\_two.size() == 2);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00218}00218 CHECK(max\_two.find(10) != max\_two.end());} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00219}00219 CHECK(max\_two.find(9) != max\_two.end());} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00220}00220 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00221}00221 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00222}00222 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00223}\mbox{\hyperlink{algorithm_8cpp_a20a0a491f45512e2734aa49e3121fb2f}{00223}} \mbox{\hyperlink{algorithm_8cpp_ac637be6eb28e3385a0eec3896b522c7a}{TEST\_CASE}}(\textcolor{stringliteral}{"{}general algorithms"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00225}00225 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00226}00226 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00227}\mbox{\hyperlink{algorithm_8cpp_a956d6cbf06ae106b6b96fc7b779ff887}{00227}} \mbox{\hyperlink{algorithm_8cpp_ac637be6eb28e3385a0eec3896b522c7a}{TEST\_CASE}}(\textcolor{stringliteral}{"{}assorted algorithms"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00228}00228 \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{equal}} = [](\textcolor{keyword}{auto} r1, \textcolor{keyword}{auto} r2) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00229}00229 \textcolor{keyword}{auto} r1b = r1.begin();} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00230}00230 \textcolor{keyword}{auto} r1e = r1.end();} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00231}00231 \textcolor{keyword}{auto} r2b = r2.begin();} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00232}00232 \textcolor{keyword}{auto} r2e = r2.end();} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00233}00233 \textcolor{keywordflow}{return} (std::distance(r1b, r1e) == std::distance(r2b, r2e))} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00234}00234 and \mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{kblib::equal}}(r1b, r1e, r2b);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00235}00235 \};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00236}00236 std::array haystack\{1, 1, 2, 5, 6, 2, 4, 7, 0, 6\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00237}00237 \textcolor{keyword}{const} \textcolor{keywordtype}{int} N = 5;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00238}00238 std::array maxN\_target\{7, 6, 6, 5, 4\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00239}00239 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00240}00240 CHECK(\mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{equal}}(maxN\_target, \mbox{\hyperlink{namespacekblib_a73a566130ecb9a7b37b0db0952a53404}{kblib::get\_max\_n}}>(} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00241}00241 haystack.begin(), haystack.end(), N)));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00242}00242 std::vector maxN\_copy;} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00243}00243 \mbox{\hyperlink{namespacekblib_a73a566130ecb9a7b37b0db0952a53404}{kblib::get\_max\_n}}(haystack.begin(), haystack.end(),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00244}00244 std::back\_inserter(maxN\_copy), 5);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00245}00245 CHECK(\mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{equal}}(maxN\_target, maxN\_copy));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00246}00246 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00247}00247 CHECK(} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00248}00248 \mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{equal}}(maxN\_target, \mbox{\hyperlink{namespacekblib_a73a566130ecb9a7b37b0db0952a53404}{kblib::get\_max\_n}}>>(} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00249}00249 haystack.begin(), haystack.end(), N)));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00250}00250 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00251}00251 std::vector maxN\_psc(N);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00252}00252 std::partial\_sort\_copy(haystack.begin(), haystack.end(), maxN\_psc.begin(),} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00253}00253 maxN\_psc.end(), std::greater<>\{\});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00254}00254 CHECK(\mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{equal}}(maxN\_target, maxN\_psc));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00255}00255 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00256}00256 \textcolor{comment}{// SFINAE prevents get\_max\_n from being called with invalid arguments,}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00257}00257 \textcolor{comment}{// even though count has moved from third to fourth on this overload.}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00258}00258 \textcolor{comment}{// It will also fail when the output range is not assignable.}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00259}00259 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00260}00260 \textcolor{comment}{// kblib::get\_max\_n(haystack.begin(), haystack.end(), maxN.cbegin(),}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00261}00261 \textcolor{comment}{// 1); kblib::get\_max\_n(haystack.begin(), haystack.end(), 1,}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00262}00262 \textcolor{comment}{// maxN.begin());}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00263}00263 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00264}00264 \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a72690688922a2d4ae9a3e46ff0c1a9a9}{range}} = \mbox{\hyperlink{namespacekblib_a72690688922a2d4ae9a3e46ff0c1a9a9}{kblib::range}}(0, 50, 3);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00265}00265 CHECK(\mbox{\hyperlink{namespacekblib_afbec3807c1be9d0aea88c620d673823c}{equal}}(\mbox{\hyperlink{namespacekblib_a72690688922a2d4ae9a3e46ff0c1a9a9}{range}}, std::vector\{0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30,} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00266}00266 33, 36, 39, 42, 45, 48\}));} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00267}00267 \textcolor{keyword}{auto} maxN\_range} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00268}00268 = kblib::get\_max\_n>(\mbox{\hyperlink{namespacekblib_a72690688922a2d4ae9a3e46ff0c1a9a9}{range}}.begin(), \mbox{\hyperlink{namespacekblib_a72690688922a2d4ae9a3e46ff0c1a9a9}{range}}.end(), 5);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00269}00269 CHECK(maxN\_range == std::vector\{48, 45, 42, 39, 36\});} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00270}00270 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00271}00271 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00272}\mbox{\hyperlink{algorithm_8cpp_a62f41abdbd63a179ff35df6d097a50e3}{00272}} \mbox{\hyperlink{algorithm_8cpp_ac637be6eb28e3385a0eec3896b522c7a}{TEST\_CASE}}(\textcolor{stringliteral}{"{}zip"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00273}00273 SECTION(\textcolor{stringliteral}{"{}non-\/overlapping"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00274}00274 std::vector input1\{1, 2, 3, 4, 5, 6\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00275}00275 std::vector input2\{2, 3, 4, 5, 6, 7\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00276}00276 } \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00277}00277 \textcolor{keywordflow}{for} (\textcolor{keyword}{auto} t : \mbox{\hyperlink{namespacekblib_a0768784de97af5384c76b4009f22fb31}{kblib::zip}}(input1.begin(), input1.end(), input2.begin())) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00278}00278 \textcolor{keyword}{auto}\& \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}} = std::get<0>(t);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00279}00279 \textcolor{keyword}{auto}\& b = std::get<1>(t);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00280}00280 CHECK(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}} + 1 == b);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00281}00281 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00282}00282 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00283}00283 SECTION(\textcolor{stringliteral}{"{}identical"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00284}00284 std::vector input\{1, 2, 3, 4, 5, 6, 7, 8\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00285}00285 \textcolor{keywordflow}{for} (\textcolor{keyword}{auto} t : \mbox{\hyperlink{namespacekblib_a0768784de97af5384c76b4009f22fb31}{kblib::zip}}(input.begin(), input.end(), input.begin())) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00286}00286 \textcolor{keyword}{auto}\& \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}} = std::get<0>(t);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00287}00287 \textcolor{keyword}{auto}\& b = std::get<1>(t);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00288}00288 CHECK(\&\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}} == \&b);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00289}00289 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00290}00290 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00291}00291 SECTION(\textcolor{stringliteral}{"{}overlapping"{}}) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00292}00292 std::vector input\{1, 2, 3, 4, 5, 6, 7, 8\};} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00293}00293 \textcolor{keywordflow}{for} (\textcolor{keyword}{auto} t :} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00294}00294 \mbox{\hyperlink{namespacekblib_a0768784de97af5384c76b4009f22fb31}{kblib::zip}}(input.begin(), input.end() -\/ 1, input.begin() + 1)) \{} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00295}00295 \textcolor{keyword}{auto}\& \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}} = std::get<0>(t);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00296}00296 \textcolor{keyword}{auto}\& b = std::get<1>(t);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00297}00297 CHECK(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}} + 1 == b);} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00298}00298 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00299}00299 \}} \DoxyCodeLine{\Hypertarget{algorithm_8cpp_source_l00300}00300 \}} \end{DoxyCode}