D
dgront
Greetings! I believe someone can spare me a minute and give me some
ideas.
Once upon a time I had a C program:
double propert[100];
char symb[100];
char* descript[100];
But now I want to make it in C++. So:
class SingleData {
public:
double propert;
char symbol;
string descript;
void doSomething(...);
};
vector<SingleData> my_data;
But I need to iterate over SingleData as well as over each field of the
class. The efficiency is crucial. And now I came to the problem:
How should I implement iterators for symbol, propert and descript? I
want them (eg. iterator over SingleData:ropert) to behave like
vector<double>propert::iterator. It would be nice, if I could use
algorithms from STL (eg. max, min) for those iterators. Can it be as
fast as accesing raw data in the C implementation?
Implementation like:
vector<double> propert;
vector<string> descript;
vector<char> symb;
is not an option, because sometimes I have to pass a whole SingleData*
object
Dominik Gront
ideas.
Once upon a time I had a C program:
double propert[100];
char symb[100];
char* descript[100];
But now I want to make it in C++. So:
class SingleData {
public:
double propert;
char symbol;
string descript;
void doSomething(...);
};
vector<SingleData> my_data;
But I need to iterate over SingleData as well as over each field of the
class. The efficiency is crucial. And now I came to the problem:
How should I implement iterators for symbol, propert and descript? I
want them (eg. iterator over SingleData:ropert) to behave like
vector<double>propert::iterator. It would be nice, if I could use
algorithms from STL (eg. max, min) for those iterators. Can it be as
fast as accesing raw data in the C implementation?
Implementation like:
vector<double> propert;
vector<string> descript;
vector<char> symb;
is not an option, because sometimes I have to pass a whole SingleData*
object
Dominik Gront