Example usage for java.util Collection size

List of usage examples for java.util Collection size

Introduction

In this page you can find the example usage for java.util Collection size.

Prototype

int size();

Source Link

Document

Returns the number of elements in this collection.

Usage

From source file:Main.java

public static boolean isCollectionEmpty(Collection<?> collection) {
    return collection == null || collection.size() == 0;
}

From source file:Main.java

/** Convert a Collection of Bytes to a primitive array byte[]. */
public static byte[] unboxBytes(Collection<Byte> coll) {
    byte[] res = new byte[coll.size()];
    int i = 0;/*from www  .j  av  a2 s . co m*/
    for (Byte elem : coll)
        res[i++] = elem;
    return res;
}

From source file:Main.java

public static boolean isEmpty(final Collection collection) {
    return collection == null || collection.size() == 0;
}

From source file:Main.java

public static boolean isNotEmpty(final Collection collection) {
    return collection != null && collection.size() > 0;
}

From source file:Main.java

public static final boolean isEmpty(Collection<?> collection) {
    return (collection == null || collection.size() == 0);
}

From source file:Main.java

public static int getSize(Collection<?> collection) {
    return collection == null ? 0 : collection.size();
}

From source file:Main.java

public static <A> Set<A> makeSet(Collection<A> xs) {
    if (xs.size() == 0)
        return Collections.<A>emptySet();
    else if (xs.size() == 1)
        return Collections.singleton(xs.iterator().next());
    else {// w ww. ja v  a2s.  co m
        Set<A> set = new HashSet<A>(xs.size());
        set.addAll(xs);
        return set;
    }
}

From source file:Main.java

private static <T extends Comparable<T>> T getExtremum(Collection<T> vals, int comparator) {
    if (vals.size() == 0)
        return null;
    Iterator<T> it = vals.iterator();
    T ret = it.next();/*from   www .  j a va 2  s .c  o m*/
    while (it.hasNext()) {
        T v = it.next();
        if (v.compareTo(ret) * comparator > 0)
            ret = v;
    }
    return ret;
}

From source file:Main.java

public static boolean isEmpty(Collection<?> collection) {
    if (collection == null || collection.size() == 0)
        return true;

    return false;
}

From source file:Main.java

public static boolean isEmpty(Collection<?> collection) {
    return collection.isEmpty() || collection.size() == 0;
}