Add method WellContainer::well_index()

This commit is contained in:
Joakim Hove 2021-05-21 20:48:31 +02:00
parent da94a16d3e
commit 8e0ed53207
2 changed files with 18 additions and 0 deletions

View File

@ -53,6 +53,9 @@ public:
this->add(name, value);
}
bool empty() const {
return this->index_map.empty();
}
std::size_t size() const {
return this->m_data.size();
@ -155,6 +158,14 @@ public:
return this->m_data;
}
std::optional<int> well_index(const std::string& wname) const {
auto index_iter = this->index_map.find(wname);
if (index_iter != this->index_map.end())
return index_iter->second;
return {};
}
private:
void update_if(std::size_t index, const std::string& name, const WellContainer<T>& other) {

View File

@ -516,6 +516,13 @@ BOOST_AUTO_TEST_CASE(TESTWellContainer) {
BOOST_CHECK(wci.has("W1"));
BOOST_CHECK_EQUAL(wci[1], 2);
BOOST_CHECK_EQUAL(wci["W3"], 3);
auto w3 = wci.well_index("W3");
BOOST_CHECK(w3.has_value());
BOOST_CHECK_EQUAL(w3.value(), 2);
auto wx = wci.well_index("WX");
BOOST_CHECK(!wx.has_value());
}