Stuart McCulloch | 3fdcd85 | 2011-10-17 10:31:43 +0000 | [diff] [blame] | 1 | package aQute.lib.collections; |
| 2 | |
| 3 | import java.util.*; |
| 4 | |
| 5 | public class Logic { |
| 6 | |
| 7 | public static <T> Collection<T> retain( Collection<T> first, Collection<T> ... sets) { |
| 8 | Set<T> result = new HashSet<T>(first); |
| 9 | for ( Collection<T> set : sets ) { |
| 10 | result.retainAll(set); |
| 11 | } |
| 12 | return result; |
| 13 | } |
| 14 | |
| 15 | public static <T> Collection<T> remove( Collection<T> first, Collection<T> ... sets) { |
| 16 | Set<T> result = new HashSet<T>(first); |
| 17 | for ( Collection<T> set : sets ) { |
| 18 | result.removeAll(set); |
| 19 | } |
| 20 | return result; |
| 21 | } |
| 22 | } |