vector iteration
Jun 24, 2016 at 1:14pm UTC
Hello,
This is a simplified code. Do you think can I write the code like that or there is a better way of doing that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
class A {
private :
std::vector<int > a_;
std::string c_;
public :
// ...
};
using Aiterator = typename std::vector<A>::iterator
class B {
private :
std::vector<class A> d_;
double e_;
public :
// ...
};
using Biterator = typename std::vector<B>::iterator
class C{
private :
std::vector<class B> b_;
public :
C();
~C();
Biterator findA(int val);
};
Biterator findA(int val){
for (const auto & BB : b_){
Aiterator ab = BB.d_.begin(), ae = BB.d_.end();
return std::find_if(ab, ae, val
{
return (val == BB.a_.getfunction());
})
}
}
Jun 24, 2016 at 2:03pm UTC
[is there] a better way of doing that?
It depends on that you're trying to do and why. Can you describe the problem? You're creating a vector of vectors of vectors, which could get very large very fast. There may be an easier way.
Topic archived. No new replies allowed.