List of usage examples for java.util List size
int size();
From source file:Main.java
public static <T> T fifth(List<T> list) { if (list.size() < 5) { throw new NoSuchElementException("Collection does not have a enough elements"); }/*from w ww . j a va2 s .c o m*/ return list.get(4); }
From source file:Main.java
/** * /*from w ww.j av a 2 s. c o m*/ * @param <T> * @param list * @return */ public static <T> T getFirstElementFromList(List<T> list) { return list.size() > 0 ? list.get(0) : null; }
From source file:Main.java
public static <E> E last(List<E> list) { return list.get(list.size() - 1); }
From source file:Main.java
private static <T> List<T> deleteAll(List<T> list, T valueToDelete) { List<T> result = new ArrayList<T>(list.size()); for (T value : list) { if (!value.equals(valueToDelete)) { result.add(value);/* w w w .j av a 2 s . co m*/ } } return result; }
From source file:Main.java
public static boolean isEmptyList(List<?> l) { return l == null || l.size() == 0; }
From source file:Main.java
public static <E> E safeGet(List<E> list, int index) { return list.size() > index ? list.get(index) : null; }
From source file:Main.java
public static <I> boolean isEmpty(List<I> xs) { return xs == null || xs.size() == 0; }
From source file:Main.java
public static <T> List<T> tail(List<T> list) { if (list.size() == 0) { throw new IllegalStateException("tail of empty list"); }//from w ww . jav a2s. co m List<T> workList = copy(list); workList.remove(0); return Collections.unmodifiableList(workList); }
From source file:Main.java
public static boolean isEmpty(List list) { return list == null || list.size() < 1; }
From source file:Main.java
public static boolean emptyList(List list) { return list == null || list.size() == 0; }