1 #ifndef JULIAN_VECTOROPERATIONS_HPP 2 #define JULIAN_VECTOROPERATIONS_HPP 28 std::vector<T> result;
36 if ( v1.at(i) < v2.at(j) ) {
37 result.push_back(v1.at(i));
39 }
else if ( v1.at(i) > v2.at(j) ) {
40 result.push_back(v2.at(j));
42 }
else if ( v1.at(i) == v2.at(j) ) {
43 result.push_back(v2.at(j));
49 std::copy(v2.begin() + j, v2.end(), std::back_inserter(result));
52 std::copy(v1.begin() + i, v1.end(), std::back_inserter(result));
67 std::ostream& operator<<(std::ostream& s, std::vector<T>& v) {
70 for(
int i = 0; i < n; i++)
71 s << v.at(i) << std::endl;
85 template <
typename T,
typename S>
86 void sort_vectors(std::vector<T>& benchmark, std::vector<S>& sorted) {
88 std::vector<std::size_t> p(benchmark.size());
89 std::iota(p.begin(), p.end(), 0);
90 std::sort(p.begin(), p.end(),[&](std::size_t i, std::size_t j){
return benchmark[i] < benchmark[j]; });
92 std::vector<bool> done(benchmark.size());
93 for (std::size_t i = 0; i < benchmark.size(); ++i) {
98 std::size_t prev_j = i;
101 std::swap(benchmark[prev_j], benchmark[j]);
102 std::swap(sorted[prev_j], sorted[j]);
Definition: cadHoliday.cpp:3
std::vector< T > combineVectors(std::vector< T > v1, std::vector< T > v2)
Combines vector v1 and v2 without duplicates.
Definition: vectorOperations.hpp:27
void sort_vectors(std::vector< T > &benchmark, std::vector< S > &sorted)
Sorting one vector basic on contents of another.
Definition: vectorOperations.hpp:86