blob: 6daeaadb4aa7e79c8e3381c5801d9e01a8b8853b [file] [log] [blame]
Stuart McCullochbb014372012-06-07 21:57:32 +00001package aQute.lib.collections;
2
3import java.util.*;
4
5public class Logic {
Stuart McCulloch2286f232012-06-15 13:27:53 +00006
7 public static <T> Collection<T> retain(Collection<T> first, Collection<T>... sets) {
Stuart McCullochbb014372012-06-07 21:57:32 +00008 Set<T> result = new HashSet<T>(first);
Stuart McCulloch2286f232012-06-15 13:27:53 +00009 for (Collection<T> set : sets) {
Stuart McCullochbb014372012-06-07 21:57:32 +000010 result.retainAll(set);
11 }
12 return result;
13 }
Stuart McCulloch2286f232012-06-15 13:27:53 +000014
15 public static <T> Collection<T> remove(Collection<T> first, Collection<T>... sets) {
Stuart McCullochbb014372012-06-07 21:57:32 +000016 Set<T> result = new HashSet<T>(first);
Stuart McCulloch2286f232012-06-15 13:27:53 +000017 for (Collection<T> set : sets) {
Stuart McCullochbb014372012-06-07 21:57:32 +000018 result.removeAll(set);
19 }
20 return result;
21 }
22}