01: /* *****************************************************************************
02: * SetUils.java
03: * ****************************************************************************/
04:
05: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
06: * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
07: * Use is subject to license terms. *
08: * J_LZ_COPYRIGHT_END *********************************************************/
09:
10: package org.openlaszlo.utils;
11:
12: import java.util.*;
13:
14: /**
15: * A utility class containing set utility functions.
16: *
17: * @author Oliver Steele
18: */
19: public abstract class SetUtils {
20: public static boolean containsAny(Set a, Set b) {
21: for (Iterator iter = b.iterator(); iter.hasNext();) {
22: if (a.contains(iter.next())) {
23: return true;
24: }
25: }
26: return false;
27: }
28:
29: public static Set intersection(Set a, Set b) {
30: Set c = new HashSet();
31: for (Iterator iter = b.iterator(); iter.hasNext();) {
32: Object e = iter.next();
33: if (a.contains(e)) {
34: c.add(e);
35: }
36: }
37: return c;
38: }
39: }
|