Set and Map
Put object in to set/map
struct Myobject {
int val;
int pos;
// asending order
bool operator < (const Myobject& obj) const {
return val < obj.val;
}
}struct Comparator {
bool operator() (const Myobject& obj1, const Myobject& obj2) const {
return obj1.val < obj2.val;
}
}
set<Myobject,Comparator> mySet;Find element in BST
Find first element >= x
Find first element > x
Find last element <= x
Find last element < x
Last updated