c++ - Convert pointer to iterator in STL set / delete element in std::set using pointer -
i have set stores lot (upwards of 50k) of double type values on heap:
struct user { int id; double score; } set <user*, user_comparator_descending_score> users = new set ...
i create a
map<key, list of pointers elements in aforementioned set>
that is
map<id, vector<user*> > = new map...
now erase elements pointed key in map. use set::erase
function accepts iterators pointing element erased. correct use delete(pointer)
remove object set? quite uncertain of because set not use contiguous memory.
other solutions problem highly appreciated. keep set sorted in descending order of values. require insertion , deletion in o(logn)
. however, note deletion not value in set other key.
Comments
Post a Comment