Example usage for java.util List contains

List of usage examples for java.util List contains

Introduction

In this page you can find the example usage for java.util List contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:Main.java

public static <T> void addAllDistinct(List<T> src, List<T> des) {
    for (T item : des) {
        if (!src.contains(item)) {
            src.add(item);//from  w ww  .  j  a v a 2  s .  c o  m
        }
    }
}

From source file:Main.java

public static <T> boolean containsAny(List<T> c1, List<? extends T> c2) {
    for (T t : c2) {
        if (c1.contains(t)) {
            return true;
        }//  www.j a  v a 2 s.co  m
    }
    return false;
}

From source file:Main.java

public static List filter(String[] strs, List list) {
    for (int i = 0; i < strs.length; i++) {
        while (list.contains(strs[i]))
            list.remove(strs[i]);// w  w w  . j  ava 2  s.  co m
    }
    return list;
}

From source file:Main.java

public static <T> boolean containsAll(List<T> c1, List<? extends T> c2) {
    for (T o : c2) {
        if (!c1.contains(o)) {
            return false;
        }//  www  .  j  ava 2s  .  c om
    }
    return true;
}

From source file:Main.java

public static boolean deviceSupportGPS(Context context) {
    boolean result = false;

    final LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

    List<String> allProviders = manager.getAllProviders();

    if (allProviders.contains(LocationManager.GPS_PROVIDER)) {
        result = true;//from   w  ww  . j  a  va2s .  com
    }

    return result;
}

From source file:Main.java

public static void skipElements(XMLStreamReader reader, Integer... elements) throws XMLStreamException {
    int eventType = reader.getEventType();
    List<Integer> types = Arrays.asList(elements);
    while (types.contains(eventType)) {
        eventType = reader.next();/*from  w  ww  .ja v a 2  s  . c  o m*/
    }
}

From source file:Main.java

public static <T> boolean containsAny(List<? extends T> c1, List<? extends T> c2) {
    for (T t : c2) {
        if (c1.contains(t))
            return true;
    }/*from  w  w w.jav  a2s .c  o  m*/
    return false;
}

From source file:Main.java

public static <T> boolean containsAny(List<? super T> c1, List<? extends T> c2) {
    for (T t : c2) {
        if (c1.contains(t)) {
            return true;
        }//w w w. j a  v a  2  s.co m
    }
    return false;
}

From source file:Main.java

public static <T> boolean containsAny(List<? super T> c1, List<? extends T> c2) {
    for (T o : c2) {
        if (c1.contains(o)) {
            return true;
        }//from ww  w.  ja  v  a2  s .c o  m
    }
    return false;
}

From source file:Main.java

public static <T> boolean containsAny(List<? super T> c1, List<? extends T> c2) {
    for (T elem : c2) {
        if (c1.contains(c2)) {
            return true;
        }//from   ww  w .j  a va  2 s.  c  o  m
    }
    return false;
}