We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
是的,java
Set
类。通过 Java SE 教程:
http://download.oracle.com/javase/tutorial/集合/接口/set.html
Yes, the java
Set
class.Via Java SE tutorial:
http://download.oracle.com/javase/tutorial/collections/interfaces/set.html
我不知道任何 API,但已使用以下方法在 设置。
参考:集合操作:并集、交集、差集、对称差集、is子集,是超集
I don't know any API but have used following methods do such things on Set.
Reference: Set operations: union, intersection, difference, symmetric difference, is subset, is superset
Google Guava 库还有很多有用的方法(例如集合并集和差集)。
https://code.google.com/p/guava-libraries/wiki /CollectionUtilitiesExplained#Sets
示例(来自上面链接的页面):
The Google Guava library also has a bunch of useful methods (e.g. set union and difference).
https://code.google.com/p/guava-libraries/wiki/CollectionUtilitiesExplained#Sets
Example (from page linked above):
java.util.Set
类没有这些调用在其 API 中,但您可以组合removeAll()
、retainAll()
和addAll()
等操作来进行并集、交集,和差异。我不确定我知道您所说的域限制是什么意思。The
java.util.Set
class doesn't have those calls in its API, but you can combine operations likeremoveAll()
,retainAll()
, andaddAll()
to do union, intersection, and difference. I'm not sure I know what you mean by domain restriction.从 API 设置
您可以 '使用接受任何 Collection 作为输入参数的 keepAll、removeAll 和 addAll 方法模拟交集、差异、域限制。
Set from the API
You can 'simulate' intersection, difference, domain restriction with retainAll, removeAll and addAll method that accept any Collection as a input parameter.