Add DynamicState::find_if()

This commit is contained in:
Joakim Hove
2019-04-02 07:23:28 +02:00
parent 0d172c9a1c
commit 9e40f3be4f
2 changed files with 13 additions and 0 deletions

View File

@@ -24,6 +24,7 @@
#include <stdexcept>
#include <vector>
#include <algorithm>
#include <utility>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
@@ -152,6 +153,14 @@ class DynamicState {
return std::distance( m_data.begin() , iter );
}
template<typename P>
int find_if(P&& pred) const {
auto iter = std::find_if(m_data.begin(), m_data.end(), std::forward<P>(pred));
if( iter == this->m_data.end() ) return -1;
return std::distance( m_data.begin() , iter );
}
/// Will return the index of the first value which is != @value, or -1
/// if all values are == @value
int find_not(const T& value) const {