Add DynamicState::find_if()
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user