Re: c++ 的iteraotor

看板Programming作者 (xuchuan)時間17年前 (2008/08/25 16:08), 編輯推噓1(103)
留言4則, 1人參與, 最新討論串4/4 (看更多)
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
喔 原來有5種喔 我都不懂
08/25 20:29, 1F

08/25 20:29, , 2F
我只有曾經耍帥用了const iterator
08/25 20:29, 2F

08/25 20:29, , 3F
結果不行 乖乖用回一般的iterator
08/25 20:29, 3F

08/25 20:30, , 4F
那個const iterator跟我想像的好像不同
08/25 20:30, 4F
文章代碼(AID): #18icXhQ- (Programming)
文章代碼(AID): #18icXhQ- (Programming)