Example usage for java.util List get

List of usage examples for java.util List get

Introduction

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

Prototype

E get(int index);

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:Main.java

@SuppressWarnings("rawtypes")
public static void addComboBoxItems(JComboBox comboBox, List items) {
    for (int i = 0; i < items.size(); i++) {
        comboBox.addItem(items.get(i));
    }/*  w  w  w.  ja va  2 s  .co m*/
}

From source file:Main.java

public static <T> T getFirst(List<T> list) {
    T t = null;/*from w ww  .  ja  va 2s  . c o m*/
    if (list != null && !list.isEmpty()) {
        t = list.get(0);
    }
    return t;
}

From source file:com.github.pmerienne.trident.cf.testing.DRPCUtils.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public static Object extractSingleValue(String drpcResult) {
    List<List<Object>> values = (List) JSONValue.parse(drpcResult);
    return values.get(0).get(0);
}

From source file:Main.java

public static <T> boolean containsAny(List<? extends T> c1, List<? extends T> c2) {
    for (int i = 0; i < c2.size(); i++) {
        if (c1.contains(c2.get(i))) {
            return true;
        }/*from w  w  w .  jav a 2  s.  c  o  m*/
    }
    return false;
}

From source file:Main.java

static <E> Optional<E> max(List<E> elements, Comparator<E> comparator) {
    //TODO Implement me
    E maxValue = elements.get(0);
    int i = 0;//  w  w  w . java2  s .  c o m
    while (i <= elements.size()) {
        maxValue = comparator.compare(maxValue, elements.get(i)) > 0 ? maxValue : elements.get(i);
        i++;
    }
    return Optional.of(maxValue);
}

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);
        destination.add(object);//from w  w  w .j a  v a 2 s. c o  m
    }
}

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);
        destination.add(index, object);/*ww w .ja  v a 2 s .co m*/
    }
}

From source file:Main.java

private static int[] adaptPreviewFps(int expectedFps, List<int[]> fpsRanges) {
    expectedFps *= 1000;//from www . j  a  v a  2s .  co m
    int[] closestRange = fpsRanges.get(0);
    int measure = Math.abs(closestRange[0] - expectedFps) + Math.abs(closestRange[1] - expectedFps);
    for (int[] range : fpsRanges) {
        if (range[0] <= expectedFps && range[1] >= expectedFps) {
            int curMeasure = Math.abs(range[0] - expectedFps) + Math.abs(range[1] - expectedFps);
            if (curMeasure < measure) {
                closestRange = range;
                measure = curMeasure;
            }
        }
    }
    return closestRange;
}

From source file:Main.java

private static void product(List<String[]> results, List<List<String>> lists, int depth, String[] current) {
    for (int i = 0; i < lists.get(depth).size(); i++) {
        current[depth] = lists.get(depth).get(i);
        if (depth < lists.size() - 1)
            product(results, lists, depth + 1, current);
        else {/*w  ww .j  ava 2s.co  m*/
            results.add(Arrays.copyOf(current, current.length));
        }
    }
}

From source file:Main.java

public static Size determineTargetPictureSize(Camera.Parameters params, int desiredResolution) {
    List<Size> sizes = params.getSupportedPictureSizes();
    Size targetSize = sizes.get(0);
    int delta = Integer.MAX_VALUE;

    for (Size size : sizes) {
        int diff = Math.abs(desiredResolution - pixelCount(size));
        if (diff < delta) {
            targetSize = size;/*from  w  w  w . j a v  a2 s. co m*/
            delta = diff;
        }
    }
    return targetSize;
}