开发者

Antijoins with Groovy Collections

This is probably a silly question however, is there a simple way of doing 开发者_JAVA百科antijoins of collections in Groovy?

I know there are [equivilent ways of doing unions and intersections].

My thought on how to do this is:

List a,b; 
union(a,b) - intersection(a,b) 

However, I'm not sure if there is a difference operator for collections in groovy.


It turns out that can you can do a subtraction operation on 2 lists, and receive a list back of the disjoint collection. Just use the subtraction operator between two lists.

 listone - listtwo


Afaik, there isn't an operator our method to do this for you (might be a cool addition to groovy though)

The closest I can think of is the disjoint method which returns true if there is no intersection between lists, and false otherwise

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜