1
动我想排序vector<vector<double> >
与vector<int>
排序的一类和第二矢量一个矢量应与第一
ex A[0][1].............[N], and A[0][0] = X, A[0][1] = Y, A[0][2] = Z
A[0] = (1,5,3), A[1] = (3,2,1) A[2] = (2,8,4) after sorting
index: 0 1 2
A[0] = (1,5,3), A[1] = (2,8,4) A[2] = (3,2,1)
original index : 0 2 1
所以我写了下面的代码记录原始指标,我想用STL排序,但我不知道如何编写比较函数。
class point{
public:
point(int totalLength = 0, int elementLength = 0);
vector<vector<double> > pointSet;
vector<double> pointIndex;
};
point::point(int totalLength, int elementLength){
pointSet.resize(totalLength,vector<double>(elementLength, 0));
pointIndex.resize(elementLength);
}
和建议或其他方式来实现它?
感谢您的阅读。
为什么不引入特殊的'结构Point'而不是内部'向量'? –
Lol4t0
2013-05-04 19:26:37
输入是一个常量向量<向量>。 –
2013-05-04 19:28:20
所以,你有机会改进它,用'vector'代替(如果它实际上是点的矢量)。想想看。 –
Lol4t0
2013-05-04 19:29:47