Re: c++ 的iteraotor
nth_element和partial_sort都要求random access iterator,而map的iterator是
bidirectional,不能用。
iterator一共是五種:input,output,forward,bidirectional,random access
※ 引述《xrancyma@kkcity.com.tw ( )》之銘言:
: ※ 引述《sorryChen.bbs@ptt.cc (陳揚和)》之銘言:
: > 先說是個笨問題..
: > it++ 可以 it-- 倒退好像就不行 對嗎
: > 我是說像是map中的iterator,內部是遞增排列的吧
: > 但其實每次都想要拿最大的那幾個...有辦法比較快拿到嗎
: 1. 曳代器有分 向前、向後、雙向。
: 2. 其實你可以使用 nth_element 或 partial_sort
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 221.218.193.92
推
08/25 20:29, , 1F
08/25 20:29, 1F
→
08/25 20:29, , 2F
08/25 20:29, 2F
→
08/25 20:29, , 3F
08/25 20:29, 3F
→
08/25 20:30, , 4F
08/25 20:30, 4F
討論串 (同標題文章)