dictionary - Performance in Nesting three maps Vs Separate maps in C++ -
i confused choose between 2 methods have stl structure ,
method a:
map<pair<string,int>,map<string,map<ulong,vector<string>>*>*>
method b:
is above advisable or having separate maps below,
map<pair<string,int>,vector<string>>
after querying parent map , iterating vector , query second map
map<string,map<ulong,vector<string>>*>
out of above 2 methods optimal way , cause more performance overhead?
update 1:
my target store output logs in memory has 3 groups.. outermost key "pair" parent grouping , has it's own sub groups.. , each sub groups have it's own groups.
after typedef method a:
typedef map<ulong,vector<string>> sub_map2; typedef map<string,sub_map2*> sub_map1; typedef map<pair<string,int>,sub_map1*> parent_map;
for better readability
don't go premature optimization. use clean code , try optimize if see bottleneck in code. use typedef's in order maintain readability.
i.e. (i don't know how want organize it).
typedef map<ulong, vector<string>> idlogmap; typedef map<pair<string, int>, idlogmap> pairlogmap;
anyway suggest refactor bit code, creating log message class , on, because map<pair<string,int>,map<string,map<ulong,vector<string>>*>*>
it's bit complicated me, if want obtain specific log message. also, try avoid raw pointers.
Comments
Post a Comment