yash cp
yash cp

Reputation: 193

Find Unique Sets in an ArrayList of Sets in Java

I have an ArrayList of Sets , I would like to find the unique sets among this ArrayList of Sets .

Please help me regarding this.

Upvotes: 0

Views: 955

Answers (1)

NPE
NPE

Reputation: 500367

Let's call your ArrayList<Set<T>> al. You can put its elements into a Set:

Set<Set<T>> unique = new HashSet<Set<T>>(al);

The elements of unique will give you the unique sets.

P.S. In the above, T is some type (you haven't told us what it is, so I've used a generic name).

Upvotes: 5

Related Questions