I'm having a set of approximately 150 variables that can have different type (double, bool, array). This set of variables I need to pack into a QVector. Because of type variables vary I thought of using QVariant. So far this is my design. What I'm not sure is the performance + the search mechanism of myVariables.
enum class VariableEnums{
VAR1,
VAR2,
VAR3
};
struct myVariable{
VariableEnums var;
QVariant value;
};
QVector<myVariable> myVariables;
The idea is that myVariables will be send to several modules. Each module will find a specific variable and update some other variable. So one module can update variable that will be used by another module. So far regarding searching a specific variable I can think only following:
foreach(myVariable *myVar, myVariables{
if(myVar->var == VariableEnums::VAR1){
//......
continue;
}
}
Is there some more effective way to do this? I could use indexOf, but I'm not sure how to use it with a structure.
thanks, m.
after doing some profiling it turned out that QVector with a struct of enums was the fastest combination. QVector
I have tried QHash, QMap and for data holders QString and QVariant
benchmark: