难道有升压集合运算的数据类型是比STL更简单呢? [英] Does boost have a datatype for set operations that is simpler than the STL?
本文介绍了难道有升压集合运算的数据类型是比STL更简单呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我觉得做简单的设置的操作十分笨重使用的C ++ STL方法。例如,要查找两个集合之间的区别是:
I find the C++ STL method of doing simple set operations quite clunky to use. For example, to find the difference between two sets:
std::set<int> newUserIds;
set_difference(currentUserIds.begin(), currentUserIds.end(), mPreviousUserIds.begin(), mPreviousUserIds.end(), std::inserter(newUserIds, newUserIds.end()));
std::set<int> missingUserIds;
set_difference(mPreviousUserIds.begin(), mPreviousUserIds.end(), currentUserIds.begin(), currentUserIds.end(), std::inserter(missingUserIds, missingUserIds.end()));
mPreviousUserIds = currentUserIds;
是否提振可供选择组类,将上面的例子中减少这样的事情:
Does boost offer an alternative set of classes that would reduce the above example to something like this:
set_type<int> newUserIds = currentUserIds.difference(mPreviousUserIds);
set_type<int> missingUserIds = mPreviousUserIds.difference(currentUserIds);
(类似展示Qset Qt中它覆盖运营商 -
以这种方式)
(Similar to QSet in Qt which overrides operator-
in this way.)
推荐答案
请参阅Boost范围设定算法的。他们仍然期待一个输出迭代器虽然。
See Boost Range Set algorithms. They still expect an output iterator though.
这篇关于难道有升压集合运算的数据类型是比STL更简单呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文