Example usage for java.util List size

List of usage examples for java.util List size

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of elements in this list.

Usage

From source file:Main.java

public static <T> void addAllInReverseOrder(Collection<T> destination, List<T> source) {
    for (int i = source.size() - 1; i >= 0; i--) {
        T object = source.get(i);//ww  w  .  j a  v a  2 s.com
        destination.add(object);
    }
}

From source file:Main.java

public static <T> void addAllInReverseOrder(List<T> destination, int index, List<T> source) {
    for (int i = source.size() - 1; i >= 0; i--) {
        T object = source.get(i);//from  w  ww.j a va  2  s .  c  o m
        destination.add(index, object);
    }
}

From source file:Main.java

/**
 * Returns the given list with the given element added at the end.
 * If it is an empty list, a new list is created. Otherwise, the given list is reused. 
 * This method is especially useful for dealing with immutable empty lists,
 * which are used to save memory.//from   ww w. j  ava 2 s  .c om
 */
public static <T> List<T> addOrNew(List<T> list, T element) {
    if (list.size() == 0)
        list = new ArrayList<T>(1);
    list.add(element);
    return list;
}

From source file:Main.java

public static boolean isNotEmpty(List<?> list) {
    if (null == list || list.size() == 0) {
        return false;
    }//w ww  .j ava 2 s.c  om
    return true;
}

From source file:Main.java

public static boolean hasEle(List images) {
    if (images == null || images.size() == 0) {
        return false;
    } else {//from ww w.  j ava  2s  .  c om
        return true;
    }
}

From source file:Main.java

public static <V> int getAdapterCount(List<V> mList) {
    return mList == null ? 0 : mList.size();
}

From source file:Main.java

public static <T> boolean listIsNull(List<T> list) {
    if (list == null || list.size() == 0) {
        return true;
    }// w w w. ja  va2s . com
    return false;

}

From source file:Main.java

public static boolean isListValid(List<?> list) {
    if (list != null && list.size() > 0) {
        return true;
    } else {/*from  w  w  w. jav  a2 s  .c  o  m*/
        return false;
    }
}

From source file:Main.java

public static Object last(List<Object> elements) {
    return elements.get(elements.size());
}

From source file:Main.java

public static long[] LongListTolongArray(List<Long> lg) {
    long[] l = new long[lg.size()];
    for (int i = 0; i < lg.size(); i++) {
        l[i] = lg.get(i).longValue();/* w w w.j  a  v a 2s .c  o m*/
    }
    return l;
}