Shamrock
2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shambase
include
shambase
sets.hpp
Go to the documentation of this file.
1
// -------------------------------------------------------//
2
//
3
// SHAMROCK code for hydrodynamics
4
// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5
// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6
// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7
//
8
// -------------------------------------------------------//
9
10
#pragma once
11
19
#include <set>
20
#include <vector>
21
22
namespace
shambase
{
23
40
template
<
class
T,
class
Container1,
class
Container2>
41
inline
void
set_diff
(
42
Container1
&
c1
,
43
Container2
&
ref
,
44
std::vector<T> &
missing
,
45
std::vector<T> &
matching
,
46
std::vector<T> &
extra
) {
47
48
std::set<T>
dd_ids
;
49
50
for
(
auto
a
:
c1
) {
51
dd_ids
.insert(
a
);
52
}
53
54
for
(
auto
a
:
ref
) {
55
if
(
dd_ids
.find(
a
) ==
dd_ids
.end()) {
56
missing
.push_back(
a
);
57
}
else
{
58
matching
.push_back(
a
);
59
}
60
dd_ids
.erase(
a
);
61
}
62
63
for
(
auto
a
:
dd_ids
) {
64
extra
.push_back(
a
);
65
}
66
}
67
}
// namespace shambase
shambase
namespace for basic c++ utilities
Definition
sycl_builtins.hpp:25
shambase::set_diff
void set_diff(Container1 &c1, Container2 &ref, std::vector< T > &missing, std::vector< T > &matching, std::vector< T > &extra)
Compute the difference between two containers as three separate vectors.
Definition
sets.hpp:41
shambase::throw_with_loc
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
Definition
exception.hpp:132
Generated on Wed May 13 2026 13:21:49 for Shamrock by
1.9.8