Is there ready function to get difference of two std::list lists?
For example I have list1: obj1, obj2, obj3, obj4 and list2: obj2, obj3, obj4, obj5.
The function result should be list1_unique: obj1, list1_and_list2: obj2, obj3, obj4, list2_unique: obj5.
(It's not hard to write my own implementation but I would prefer standard function)
If your lists are sorted (as your examples appear to be), std::set_difference to get list1_unique and list2_unique, and std::set_intersection to get list1_and_list2. If they're not already sorted, you could sort them with std::list::sort().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With