List of usage examples for java.util Collection contains
boolean contains(Object o);
From source file:PlanetSet.java
public static void main(String args[]) { String names[] = { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto" }; Collection planets = new ArrayList(); for (int i = 0, n = names.length; i < n; i++) { planets.add(names[i]);//from w w w .j a v a 2s . c o m } String s[] = (String[]) planets.toArray(new String[0]); for (int i = 0, n = s.length; i < n; i++) { System.out.println(s[i]); } planets.remove(names[3]); System.out.println(names[1] + " " + planets.contains(names[1])); System.out.println(names[3] + " " + planets.contains(names[3])); }
From source file:Main.java
public static boolean isElement(String e, Collection<String> c) { if (c.contains(e)) return true; else//from ww w . j a v a2 s. co m return false; }
From source file:Main.java
public static Object ifNotIn(Object o, Collection c, Object alternative) { return c.contains(o) ? o : alternative; }
From source file:Main.java
private static boolean nodeNameMatch(Node node, Collection<?> desiredNames) { return (desiredNames.contains(node.getNodeName()) || desiredNames.contains(node.getLocalName())); }
From source file:Main.java
public static boolean contains(Collection collection, Long object) { return collection.contains(object); }
From source file:Main.java
public static <T> void add_new(Collection<T> target, T element) { if (!(target.contains(element))) target.add(element);/*from w w w . j a v a 2 s . c o m*/ }
From source file:Main.java
public static <T> void addIfNotExist(T item, Collection<T> col) { if (!col.contains(item)) { col.add(item);// w ww. ja v a 2s . c o m } }
From source file:Main.java
public static <T> boolean allContains(final T element, final Collection<T>... colls) { for (final Collection<T> coll : colls) if (!coll.contains(element)) return false; return true;/*from ww w . j a v a2 s .c o m*/ }
From source file:Main.java
private static boolean nodeNameMatch(Node node, Collection desiredNames) { return (desiredNames.contains(node.getNodeName()) || desiredNames.contains(node.getLocalName())); }
From source file:Main.java
public static <K> boolean isIntersectingWith(Collection<K> a, Collection<K> b) { for (K v : a) { if (b.contains(v)) return true; }//from ww w . j ava 2 s .co m return false; }