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
On May 6, 2015 5:11:51 AM EDT, Uthpal Urubail
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?]
Not sure I quite understand the question, but have a look at cpplinq to_map. http://github.com/mrange/cpplinq/ Your tolerance function should be able to serve as the key, with instances (or whatever) as predicated values. Very similar in nature as with .NET LINQ, works great, and you can specify lambdas, which I find very helpful.
Any help is highly appreciated.
HTH
Regards, UJ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Sent from my Android device with K-9 Mail. Please excuse my brevity.
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
participants (3)
-
Michael
-
U.Mutlu
-
Uthpal Urubail