c++ STL set difference

后端 未结 10 1695
梦如初夏
梦如初夏 2020-12-23 11:05

Does the C++ STL set data structure have a set difference operator?

10条回答
  •  执念已碎
    2020-12-23 11:36

    Yes, there is a set_difference function in the algorithms header.

    Edits:

    FYI, the set data structure is able to efficiently use that algorithm, as stated in its documentation. The algorithm also works not just on sets but on any pair of iterators over sorted collections.

    As others have mentioned, this is an external algorithm, not a method. Presumably that's fine for your application.

提交回复
热议问题