3 #ifndef SHARECONTAINER_H
4 #define SHARECONTAINER_H
9 #include <boost/utility.hpp>
10 #include <boost/smart_ptr.hpp>
14 class ShareContainer : public noncopyable {
17 typedef std::vector<boost::shared_ptr<Share> > Params;
19 typedef typename Params::value_type value_type;
22 get(Share const & ps) const {
23 // First see if we already have this ps in the container
24 Params::iterator it = std::find_if(params.begin(),
28 if (it == params.end()) {
29 // ok we don't have it so we should
31 tmp.reset(new Share(ps));
32 params.push_back(tmp);
33 // We clean here. This can cause us to have
34 // some (one) unique elemements some times
35 // but we should gain a lot in speed.
37 //std::sort(params.rbegin(), params.rend(), comp());
39 // yes we have it already
42 if (it != params.begin())
50 isEqual(Share const & s) : p_(s) {}
51 bool operator()(value_type const & p1) const {
52 return *p1.get() == p_;
59 // int operator()(value_type const & p1,
60 // value_type const & p2) const {
61 // return p1.use_count() < p2.use_count();
66 bool operator()(value_type const & p) const {
73 // Remove all unique items. (i.e. entries that only
74 // exists in the conatainer and does not have a
75 // corresponding paragrah.
76 Params::iterator it = std::remove_if(params.begin(),
79 params.erase(it, params.end());
83 mutable Params params;