集合的有效交集? [英] Efficient intersection of sets?
问题描述
我想知道最有效的方法是什么.
I'm wondering what the most efficient way of doing this is.
我有从 2 个地方收集的积分.
I have points that I gather from 2 places.
我只对两个地方的共同点感兴趣.
I am only interested in the points which are common to both places.
我的计划是有 3 个 std::set
.首先我将区域A的点加到集合A中,然后从B点到集合B,让集合C成为两个集合的交集.
My plan is to have 3 std::set<Point>
. First I will add in the points from area A,into set A then points from B into set B and let set C be the intersection of both sets.
然而,我想知道是否有更好的方法来做到这一点,可能涉及更少的集合?
However, I'm wondering if there is a better way of doing this that involves maybe less sets?
谢谢
推荐答案
你的问题太普遍了,甚至有一个(以明显的方式命名)标准算法set_intersection()
供您使用.
Your problem is so common that there even is a (named in an obvious way) standard algorithm set_intersection()
for you to use.
这篇关于集合的有效交集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!