List of usage examples for java.util List get
E get(int index);
From source file:Main.java
public static double[] toDoubleArray(List<Double> list) { double[] result = new double[list.size()]; for (int i = 0; i < result.length; i++) result[i] = list.get(i); return result; }
From source file:Main.java
public static int[] toIntArray(List<Integer> integers) { int[] x = new int[integers.size()]; for (int i = 0; i < integers.size(); i++) x[i] = integers.get(i); return x;/*ww w . j av a2 s .c om*/ }
From source file:Main.java
public static int[] unbox(List<Integer> list) { int[] result = new int[list.size()]; for (int i = 0; i != result.length; ++i) { result[i] = list.get(i); }/*from www.java 2 s. c om*/ return result; }
From source file:Util.java
/** * Calculate the minimum and maximum values out of a list of doubles. * /*from www. ja va2 s . c om*/ * @param values * the input values * @return an array with the minimum and maximum values */ public static double[] minmax(List<Double> values) { if (values.size() == 0) { return new double[2]; } double min = values.get(0); double max = min; int length = values.size(); for (int i = 1; i < length; i++) { double value = values.get(i); min = Math.min(min, value); max = Math.max(max, value); } return new double[] { min, max }; }
From source file:Main.java
public static <T> T search(SortedSet<T> set, T element) { T o = null;//from w w w. j a v a2 s.c om List l = new ArrayList(set); int index = Collections.binarySearch(l, element); if (index >= 0) { o = (T) l.get(index); } return o; }
From source file:Main.java
public static <T> List<T> reverse(List<T> list) { List<T> newList = new ArrayList<T>(); for (int i = list.size() - 1; i >= 0; i--) { newList.add(list.get(i)); }/* w ww . j a v a 2 s . c o m*/ return newList; }
From source file:Main.java
public static void setIfNull(int i, List list, String value) { if (i >= list.size()) { resize(list, i + 1);// w ww .jav a2s .c o m } if (list.get(i) != null) { return; } list.set(i, value); }
From source file:Main.java
/** * Converts {@link List} of Integers into an int array * * @param list list to be converted/* ww w .j a v a 2 s .c o m*/ * @return int[] representation */ public static int[] toIntArray(List<Integer> list) { int[] array = new int[list.size()]; for (int i = 0; i < list.size(); i++) { array[i] = list.get(i); } return array; }
From source file:Main.java
public static String getGfycatId(String in) { Uri uri = Uri.parse(in);/*from ww w .ja v a2s. c o m*/ final String host = uri.getHost(); if (TextUtils.isEmpty(host) == false && host.endsWith("gfycat.com") == true) { List<String> paths = uri.getPathSegments(); if (paths.size() == 1) { return paths.get(0); } else if (paths.size() == 2) { return paths.get(1); } } return null; }
From source file:Main.java
public static double[] toPrimitiveDouble(List<Double> list) { double[] array = new double[list.size()]; for (int i = 0; i < list.size(); i++) { array[i] = list.get(i); }//from w w w .j ava 2s . c o m return array; }