feat(composition): added contains method
This commit is contained in:
@@ -639,6 +639,19 @@ namespace serif::composition {
|
|||||||
return m_compositions.count(symbol) > 0;
|
return m_compositions.count(symbol) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Composition::contains(const serif::atomic::Species &isotope) const {
|
||||||
|
// Check if the isotope's symbol is in the composition
|
||||||
|
if (!m_finalized) {
|
||||||
|
LOG_ERROR(m_logger, "Composition has not been finalized.");
|
||||||
|
throw std::runtime_error("Composition has not been finalized (Consider running .finalize()).");
|
||||||
|
}
|
||||||
|
const auto symbol = static_cast<std::string>(isotope.name());
|
||||||
|
if (m_compositions.contains(symbol)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// OVERLOADS
|
/// OVERLOADS
|
||||||
|
|
||||||
Composition Composition::operator+(const Composition& other) const {
|
Composition Composition::operator+(const Composition& other) const {
|
||||||
|
|||||||
@@ -473,6 +473,8 @@ namespace serif::composition {
|
|||||||
*/
|
*/
|
||||||
bool hasSymbol(const std::string& symbol) const;
|
bool hasSymbol(const std::string& symbol) const;
|
||||||
|
|
||||||
|
bool contains(const serif::atomic::Species& isotope) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the composition mode.
|
* @brief Sets the composition mode.
|
||||||
* @param massFracMode True if mass fraction mode, false if number fraction mode.
|
* @param massFracMode True if mass fraction mode, false if number fraction mode.
|
||||||
|
|||||||
Reference in New Issue
Block a user