Add begin() and end() to Box.

This commit is contained in:
Joakim Hove
2016-11-11 14:41:50 +01:00
committed by jokva
parent 6869210730
commit 2b53bc4c43
3 changed files with 19 additions and 2 deletions

View File

@@ -103,6 +103,16 @@ namespace Opm {
}
std::vector<size_t>::const_iterator Box::begin() const {
return m_indexList.begin();
}
std::vector<size_t>::const_iterator Box::end() const {
return m_indexList.end();
}
const std::vector<size_t>& Box::getIndexList() const {
return m_indexList;
}

View File

@@ -38,7 +38,8 @@ namespace Opm {
bool equal(const Box& other) const;
explicit operator bool() const;
std::vector<size_t>::const_iterator begin() const;
std::vector<size_t>::const_iterator end() const;
private:
void initIndexList();

View File

@@ -53,10 +53,16 @@ BOOST_AUTO_TEST_CASE(CreateBox) {
for (i=0; i < box.getDim(0); i++) {
size_t g = i + j*box.getDim(0) + k*box.getDim(0)*box.getDim(1);
BOOST_CHECK_EQUAL( indexList[g] , g);
}
}
}
i = 0;
for (auto index : box) {
BOOST_CHECK_EQUAL( index , indexList[i]);
i++;
}
}
}