List of usage examples for java.util Collection size
int size();
From source file:Main.java
public static boolean isEmptyArray(Collection collection) { return collection == null || collection.size() == 0; }
From source file:Main.java
/** * Returns <code>true</code> if the passed collection is either <code>null</code> * or has size 0./*from w ww. ja v a2s.co m*/ */ public static boolean isEmpty(Collection<?> c) { return (c == null) ? true : (c.size() == 0); }
From source file:Main.java
public static boolean isNullOrEmpty(Collection collection) { return collection == null || collection.size() == 0; }
From source file:Main.java
/** * Check is a collection is not empty/*from w w w. j av a2 s . c o m*/ */ public static boolean isNotEmpty(Collection<?> cl) { return ((cl != null) && (cl.size() > 0)); }
From source file:Main.java
public static int[] toIntArray(Collection<Integer> is) { int[] out = new int[is.size()]; int index = 0; for (Integer i : is) out[index++] = i;/* w ww .jav a 2 s .c o m*/ return out; }
From source file:Main.java
public static <E> E getElementAtIndex(Collection<E> set, int idx) { if (idx >= set.size() || idx < 0) { throw new IndexOutOfBoundsException(); }/*from www . j a v a2 s . co m*/ Iterator<E> it = set.iterator(); for (int i = 0; i < idx; ++i) { it.next(); } return it.next(); }
From source file:Main.java
public static boolean isEmpty(Collection collection) { return (collection == null) || (collection.size() == 0); }
From source file:Main.java
public static int randomIndex(Collection<?> collection) { return new Random().nextInt(collection.size()); }
From source file:Main.java
public static <E> boolean isNotEmpty(Collection<E> collection) { return collection != null && collection.size() != 0; }
From source file:Main.java
public static boolean isListEmpty(Collection collection) { if (collection == null || collection.size() < 1) return true; else/*from w w w. j a v a2 s . c om*/ return false; }