preCICE v3.1.1
Loading...
Searching...
No Matches
ManageUniqueIDs.cpp
Go to the documentation of this file.
2#include <boost/container/detail/flat_tree.hpp>
3
4namespace precice::utils {
5
7{
8 bool notFound = true;
9 while (notFound) {
10 if (_ids.find(_lowerLimit) == _ids.end()) {
11 notFound = false;
12 }
14 }
15 _ids.insert(_ids.end(), _lowerLimit - 1);
16 return _lowerLimit - 1;
17}
18
20{
21 if (_ids.find(id) != _ids.end()) {
22 return false;
23 }
24
25 _ids.insert(_ids.end(), id);
26 return true;
27}
28
30{
31 _ids.clear();
32 _lowerLimit = 0;
33}
34
35} // namespace precice::utils
bool insertID(int id)
Inserts an ID which has to be unique.
boost::container::flat_set< int > _ids
Stores all used IDs.
int _lowerLimit
Marks next ID to be given, from lower to higher values.
void resetIDs()
Resets all retrieved and inserted IDs.
contains precice-related utilities.