mirror of https://github.com/AxioDL/amuse.git
Studio: Make _cyclicCheck a const member function
This doesn't actually modify the internal state of the studio instance, so we can mark it as a const member function.
This commit is contained in:
parent
6c07ec907a
commit
04fbc328e9
|
@ -18,7 +18,7 @@ class Studio {
|
|||
|
||||
std::list<StudioSend> m_studiosOut;
|
||||
#ifndef NDEBUG
|
||||
bool _cyclicCheck(Studio* leaf);
|
||||
bool _cyclicCheck(const Studio* leaf) const;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#include "amuse/Studio.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "amuse/Engine.hpp"
|
||||
|
||||
namespace amuse {
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool Studio::_cyclicCheck(Studio* leaf) {
|
||||
for (auto it = m_studiosOut.begin(); it != m_studiosOut.end();) {
|
||||
if (leaf == it->m_targetStudio.get() || it->m_targetStudio->_cyclicCheck(leaf))
|
||||
return true;
|
||||
++it;
|
||||
}
|
||||
return false;
|
||||
bool Studio::_cyclicCheck(const Studio* leaf) const {
|
||||
return std::any_of(m_studiosOut.cbegin(), m_studiosOut.cend(), [leaf](const auto& studio) {
|
||||
return leaf == studio.m_targetStudio.get() || studio.m_targetStudio->_cyclicCheck(leaf);
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue