2017-03-23 4 views
1

値を押し込むことでエッジのプロパティを設定できるかどうか疑問に思っていました。ブーストグラフライブラリ - ベクトルをエッジプロパティにプッシュ

struct Edge { 

    //boundary length 
    int length = 0; 

    //boundary coordinates 
    vector<cv::Point> boundary; 

    //pointer to heap 
    boost::heap::fibonacci_heap<rnn, boost::heap::compare<compare_nn>>::handle_type heap_pointer; 

    Edge(float length = 0) : length (length) {} 
}; 

//i'd like to push in point into vector<cv::Point> boundary 
boost::put(&Edge::boundary, g, boost::edge(0, 1, g), cv::Point(2,2)); 

私はバックエッジにそれを置くが、それは非常に効率的なようだ前に、私はプッシュポイントでのベクトルプロパティを得ることができます。私は誰かが私に提案を与えることを望んでいた。

答えて

1

さらに簡単:

auto& boundary = boost::get(&Edge::boundary, g, boost::edge(0, 1, g)); 
boundary.emplace_back(2,2); 

核心を取ることです参照をコピーするのではなく、ベクトルに追加します。

標準ライブラリでまだemplace_backがサポートされていない場合はもちろん、push_back(cv::Point(2,2))と綴ることができます。

0

私が正しくあなたの質問を理解していれば、私は知りませんが、ここでhelpul簡単な構造体の方法かもしれないと思わ:

struct Edge { 
    // your stuff here 
    void push(cv::Point& point) { 
    boundary.push_back(point); 
    } 
}; 
関連する問題