Sorting Sets using std::sort

前端 未结 3 2138
情深已故
情深已故 2020-12-10 04:30

I would like to know if we can sort a pre created set. When I first create the set s_p2, I sort using a different element point.getLength(). but after user input i would lik

3条回答
  •  甜味超标
    2020-12-10 04:50

    std::set stores its members in a sorted fashion. If you walk through the set from .begin() to .end(), you will have a sorted list of items.

    If you don't like the default sort criteria, you may supply a 2nd template parameter to std::set<>

提交回复
热议问题