I need my container to contain unique elements only, so I have a structure like this:
class OD
{
private:
std::string key;
public:
OD(){}
OD(const WayPoint &origin, const WayPoint &destination):
origin(origin), destination(destination)
{
std::stringstream str("");
str << origin.node_->getID() << "," << destination.node_->getID();
key = str.str();
}
bool operator<(const OD & rhs) const
{
return key < rhs.key;
}
bool operator()(const OD & rhs, const OD & lhs)
{
return rhs < lhs;
}
};
and a container :
std::set<OD,OD> t;
now I need to change my container to boost::unordered_set
type, do I need to modify the functor? I am confused because I know I can't separate order and uniqueness implementation and this time the container is not ordered . So I fear my operator()
overload would be useless.