Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A {
- public:
- void doSomething() {}
- }
- boost::unordered_map<int, boost::intrusive_ptr<A>> m;
- m.insert(0, new A());
- m.insert(1, new A());
- m.insert(2, new A());
- // later...
- std::vector<boost::intrusive_ptr<A>> f;
- boost::unordered_map<int, boost::intrusive_ptr<A>>::iterator i;
- i = m.find(0);
- f.push_back(i->second);
- i = m.find(1);
- f.push_back(i->second);
- i = m.find(2);
- f.push_back(i->second);
- // and then do operations on f:
- for(size_t i = 0; i < f.size(); ++i) {
- f[i].doSomething();
- }
- class A {
- public:
- void doSomething() {}
- }
- boost::ptr_unordered_map<int, A> m;
- m.insert(0, new A());
- m.insert(1, new A());
- m.insert(2, new A());
- // later...
- boost::ptr_vector<A> f;
- boost::ptr_unordered_map<int, A>::iterator i;
- i = m.find(0);
- f.push_back(i->second);
- i = m.find(1);
- f.push_back(i->second);
- i = m.find(2);
- f.push_back(i->second);
- // and then do operations on f:
- for(size_t i = 0; i < f.size(); ++i) {
- f[i].doSomething();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement