2009-10-01から1日間の記事一覧

mapのvalueでソートしたい

C++

PerlやRubyみたいに。stlのmapはディフォルトでキーでソートされていて、valueではできないっぽい。結論からするとpriority_queueを使うとよさそう。 #include <iostream> #include <map> #include <queue> #include <string> #include <boost/foreach.hpp> typedef std::map<std::string, int> container; typedef std::pair<std::string, int> val</std::string,></std::string,></boost/foreach.hpp></string></queue></map></iostream>…