Click to See Complete Forum and Search --> : Do I need to re-sort the set?


haoshi
March 17th, 2005, 01:03 PM
Hi all,

I have a multiset<CMyStruct*, CMyStructLess>. When I insert pointers into the set, the sequence is ordered as expected.
Now I need to change the items that the multiset pointers point to and the the sequence should be changed after my code changes the items. Does multiset sorts the set automatically?

Thanks.
Haoshi

wien
March 17th, 2005, 01:11 PM
Nope. Not when you change the value the pointer points to. You'd have to remove the pointer, change the value, and then insert it again. Otherwise the set won't know the value changed.

haoshi
March 17th, 2005, 01:15 PM
Thanks. what about the performance if I call erease() and insert().

AvDav
March 17th, 2005, 01:34 PM
I guess both take O(log(n)).