Uthpal Urubail wrote on 05/06/2015 11:11 AM:
Experts, I am looking for help on a container where I could group the objects having similar properties Ex: struct phyProp { unsigned int color; double height; double weight; std::string location; };
Can I use boost for grouping the objects having same property? [With tolerance?] Any help is highly appreciated. Regards, UJ
Use std::set with your own comparator, ie. the comparison function has to give a return value according your grouping. Add such a "less comparator" into your struct: // comparator: bool operator<(const phyProp& Other) const { if (color < Other.color) return true; if (color > Other.color) return false; if (height < Other.height) return true; if (height > Other.height) return false; //... return true; } I think boost MultiIndex should do the job too as it looks like a superset of the std containers (I unfortunately haven't used this yet, but will try it out soon). -- Uenal