c++ - QVector with struct - performance + best practise -


i'm having set of approximately 150 variables can have different type (double, bool, array). set of variables need pack qvector. because of type variables vary thought of using qvariant. far design. i'm not sure performance + search mechanism of myvariables.

enum class variableenums{   var1,   var2,   var3 };  struct myvariable{   variableenums var;   qvariant value; };  qvector<myvariable> myvariables; 

the idea myvariables send several modules. each module find specific variable , update other variable. 1 module can update variable used module. far regarding searching specific variable can think following:

foreach(myvariable *myvar, myvariables{    if(myvar->var == variableenums::var1){     //......     continue;    } } 

is there more effective way this? use indexof, i'm not sure how use structure.

thanks, m.

you consider using multimap instead of qvector. multimap can map variables like:

crude representation:

{     var1,     var1, b     var2, c     var1, d     var3, e     etc... } 

then can use multimap::equal_range() function set of variables same "key", e.g. variables key "var1".

i not sure if there qmultimap, there definatley qmap have not looked. if not use standard c++ multimap.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -