You cannot resort a set
, how it sorts is part of the type of the particular set
. A given set
has a fixed set order that cannot be changed.
You could create a new set
with the same data relatively easily. Just create a new set
that sorts based on the new criteria.
If you want to use the two set
s in the same code, you'll have to abstract the access to the underlying set
.
Now, if you are doing rare reads and modifications, using a vector
that you sort manually is often a better idea. You can remove duplicates by using the std::unique
-erase
idiom.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…