954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

std::map of std::sets. Tree evaluation problem.

Hi,


I have an expression tree in which the nodes are operators (union, intersection etc represented by a string "/u") or the nodes are std::sets.

How could I access the std::set's values in order to carry out the tree evaluation using the operator functions(set_union(), set_intersection() etc) ? The expressions are pre and postfix.

Thanks for any help, it's most appreciated.

Carrots
Junior Poster in Training
62 posts since Mar 2009
Reputation Points: 41
Solved Threads: 0
 

Use begin() and end() the way you would for any other container.

arkoenig
Master Poster
703 posts since Jun 2010
Reputation Points: 359
Solved Threads: 109
 

Thanks for your help, so you think I should implement my tree_evaluation() function to iterate through the sets, and return the values held to the set_union(), set_intersection() functions?


Thanks for giving me direction with this. I'm new to trees in general. :)

Carrots
Junior Poster in Training
62 posts since Mar 2009
Reputation Points: 41
Solved Threads: 0
 

Well... set_union and set_intersection are really intended to let you do set operations on sorted vectors. Curiously, they don't work if the destination is an actual set. So you have to implement those operations yourself using insert and erase, which, fortunately, aren't particularly different operations.

arkoenig
Master Poster
703 posts since Jun 2010
Reputation Points: 359
Solved Threads: 109
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: