P
Peter Olcott
//
// I would like to some how avoid using the global ONE
// without incurring any performance penalty in speed or space
//
#include <vector>
#include <algorithm>
struct RecType {
int AAA;
int BBB;
int CCC;
bool operator<(RecType& Text){ return this->BBB < Text.BBB; };
};
struct OneType {
std::vector<RecType> Record;
RecType& operator[](const int N){ return Record[N]; };
} ONE;
struct TwoType {
std::vector<int> Sub; // Subscripts of ONE
bool operator()(const int& N, const int& M);
void sort(){ std::sort(Sub.begin(), Sub.end(), (*this)); }
};
bool TwoType:perator()(const int& N, const int& M) {
return ONE[N] < ONE[M];
}
// I would like to some how avoid using the global ONE
// without incurring any performance penalty in speed or space
//
#include <vector>
#include <algorithm>
struct RecType {
int AAA;
int BBB;
int CCC;
bool operator<(RecType& Text){ return this->BBB < Text.BBB; };
};
struct OneType {
std::vector<RecType> Record;
RecType& operator[](const int N){ return Record[N]; };
} ONE;
struct TwoType {
std::vector<int> Sub; // Subscripts of ONE
bool operator()(const int& N, const int& M);
void sort(){ std::sort(Sub.begin(), Sub.end(), (*this)); }
};
bool TwoType:perator()(const int& N, const int& M) {
return ONE[N] < ONE[M];
}