The fastest way to find union of sets

后端 未结 7 455
说谎
说谎 2021-01-11 09:39

I have sets of pairs of int like set > x1, x2, ... xn ( n can be between 2 and 20). What is the fastest way to find union of those se

7条回答
  •  一生所求
    2021-01-11 10:34

    You could use std::set_union recursively or simply insert all sets into a result set (duplicate items are eliminated by the set). If the number of items is very small you can try to insert it all into a vector, sorting it and use std::unique on the vector.

提交回复
热议问题