あめだまふぁくとりー

Boost.Graphとかできますん

2013-01-01から1年間の記事一覧

std::pair<Iterator, Iterator>をrange based forで使用する

C++

C++11にはrange based forが加わり,rangeに対する走査処理を書くのが楽になりました.しかしながら,このstd::pair<Iterator, Iterator>で表されるIterator対はこのrangeには含まれません*1. そのため以下のようなコードはコンパイルエラーになります. #include <iostream> #include <map> in</map></iostream></iterator,>…

Boost1.55でMultiple Source Dijkstra

C++

この記事はC++ (fork) Advent Calendar 2013の22日目の記事になります. 今回も軽めの記事です.ご了承ください.Boost1.55ではBoost.Graphの関数boost::dijkstra_shortes_pathsがマルチソースに対応しましたので,本記事ではこれを紹介します. dijkstra_sh…

アルゴリズムとか意味がなかった

https://paiza.jp/poh/ec-campaign に挑戦してみましたので,そのコードを載せておきます. #include <iostream> #include <vector> #include <algorithm> template <class Iterator> inline int calc(Iterator const first, Iterator const last, int const value) { if (*(last - 1) + *(last - 2) <= va</class></algorithm></vector></iostream>…

boost::adjacency_listのVertexListテンプレート引数とvertex_indexの関係

id:faith_and_brave:20131003:1380788496に関して少しばかし補足. まず,知るべきことはboost::adjaceny_listのテンプレート引数を省略した場合である.この場合,以下の引数を指定したものとして扱われる. boost::adjacency_list< boost::vecS, // OutEdge…