本業でvectorをあんまり使わないので(使えないので)、忘れないようにvectorのソート方法のメモ。 vectorコンテナをソートする場合は、stlのalgorithmのstd::sort(クイックソート)を使うと簡単にできる。 下記は、 x,y,z情報を持ったTestPointクラスをz値が小さい順にソートする。 場合の例。 ◆比較用のクラスを使用してソート #include<algorithm> #include<iostream> #include<vector> class TestPoint { public: float x; float y; float z; }; //比較用クラス class CompPoint { public: bool operator()(const TestPoint &a,const TestPoint &b) const{ if(a.z
![std::sortのメモ](https://cdn-ak-scissors.b.st-hatena.com/image/square/126e9c63960837b5815901e11e1f6c1303c17f2b/height=288;version=1;width=512/https%3A%2F%2Fblog.seesaa.jp%2Fimg%2Fogp_logo.png)