Example usage for java.util ArrayList get

List of usage examples for java.util ArrayList get

Introduction

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

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:Main.java

private static double[] toDoubleArray(ArrayList<Double> arrayList) {
    double[] ret = new double[arrayList.size()];
    for (int i = 0; i < ret.length; i++) {
        ret[i] = arrayList.get(i);
    }//from w  ww. ja  v  a2 s . c om
    return ret;
}

From source file:FileUtils.java

public static String relativePath(String fromPath, String toPath, boolean fromIsDirectory, char separatorChar) {
    ArrayList<String> fromElements = splitPath(fromPath);
    ArrayList<String> toElements = splitPath(toPath);
    while (!fromElements.isEmpty() && !toElements.isEmpty()) {
        if (!(fromElements.get(0).equals(toElements.get(0)))) {
            break;
        }/*from   ww w  .  jav  a2 s. c o m*/
        fromElements.remove(0);
        toElements.remove(0);
    }

    StringBuffer result = new StringBuffer();
    for (int i = 0; i < fromElements.size() - (fromIsDirectory ? 0 : 1); i++) {
        result.append("..");
        result.append(separatorChar);
    }
    for (String s : toElements) {
        result.append(s);
        result.append(separatorChar);
    }
    return result.substring(0, result.length() - 1);
}

From source file:com.lucidtechnics.blackboard.util.Utility.java

public static ArrayList getAllTypes(ArrayList _searchDomainList, ArrayList _allTypesList) {
    for (int i = 0; i < _searchDomainList.size(); i++) {
        Class searchClass = (Class) _searchDomainList.get(i);
        _searchDomainList.remove(searchClass);

        Class superClass = searchClass.getSuperclass();

        if (superClass != null && (_allTypesList.contains(superClass) == false)) {
            _searchDomainList.add(superClass);
            _allTypesList.add(superClass);
        }//from   w  w w . j ava 2 s . co  m

        Class[] interfaceArray = searchClass.getInterfaces();

        if (interfaceArray != null) {
            for (int j = 0; j < interfaceArray.length; j++) {
                if (interfaceArray[j] != null && (_allTypesList.contains(interfaceArray[j]) == false)) {
                    _searchDomainList.add(interfaceArray[j]);
                    _allTypesList.add(interfaceArray[j]);
                }
            }
        }
    }

    if (_searchDomainList.isEmpty() == false) {
        _allTypesList = getAllTypes(_searchDomainList, _allTypesList);
    }

    return _allTypesList;
}

From source file:Main.java

public static double[][] toArray(ArrayList<ArrayList<Double>> a) {
    int dataDimen = a.size();
    double[][] res = new double[dataDimen][dataDimen];

    for (int i = 0; i < dataDimen; i++) {
        for (int j = 0; j < dataDimen; j++) {
            res[i][j] = a.get(i).get(j);
        }//from ww w .  j a  va2 s. c  om
    }

    return res;
}

From source file:Main.java

public static <T> ArrayList<T> distinctList(ArrayList<T> arg) {
    ArrayList<T> distinct = new ArrayList<T>();
    if (null != arg) {
        distinct = new ArrayList<T>();
        distinct.addAll(arg);//  w  w  w . ja v  a2  s . c o m
        for (int i = 0; i < distinct.size(); i++) {
            T t1 = distinct.get(i);
            for (int j = i + 1; j < distinct.size(); j++) {
                T t2 = distinct.get(j);
                if (t1.equals(t2)) {
                    distinct.remove(j);
                    j--;
                }
            }
        }
    }
    return distinct;
}

From source file:com.safecell.model.SCLicense.java

public static void insertOrUpdateLicenseKey(ArrayList<SCLicense> licenses, Context context) {

    boolean licenseIdPresent = false;

    for (int i = 0; i < licenses.size(); i++) {
        int id = licenses.get(i).getId();
        LicenseRepository licenseRepository = new LicenseRepository(context);
        licenseIdPresent = licenseRepository.licensesIdPresent(String.valueOf(id));

        if (licenseIdPresent) {
            licenseRepository.updateQuery(licenses.get(i));
            //Log.v("Safecell :"+"update", "update");
        } else {/* w w  w.j av  a2  s  .co  m*/
            licenseRepository.insertQuery(licenses.get(i));
            //Log.v("Safecell :"+"insert", "insert");
        }
    }

}

From source file:carmen.utils.Utils.java

@SuppressWarnings("unchecked")
public static LatLng getLatLngFromTweet(Map<String, Object> tweet) {
    Map<String, Object> coordinates = (Map<String, Object>) tweet.get(Constants.COORDINATES);
    if (coordinates == null)
        return null;
    ArrayList<Object> coordinateList = (ArrayList<Object>) coordinates.get(Constants.COORDINATES);

    double longitude = 0;
    if (coordinateList.get(0) instanceof Double)
        longitude = (Double) coordinateList.get(0);
    else if (coordinateList.get(0) instanceof Integer)
        longitude = (double) (Integer) coordinateList.get(0);
    else//from w w w.ja  va 2s .  co  m
        return null;

    double latitude = 0;
    if (coordinateList.get(1) instanceof Double)
        latitude = (Double) coordinateList.get(1);
    else if (coordinateList.get(1) instanceof Integer)
        latitude = (double) (Integer) coordinateList.get(1);
    else
        return null;

    LatLng latLng = new LatLng(latitude, longitude);
    return latLng;
}

From source file:Main.java

public static int[] CountElmt(ArrayList<Integer> newScores1, ArrayList<Integer> scores) {
    int a[] = new int[scores.size()];
    for (int i = 0; i < scores.size(); i++) {
        a[i] = 0;/*  w  ww.  jav a2 s . c  o m*/
    }
    for (int i = 0; i < newScores1.size(); i++) {
        int value = newScores1.get(i);
        int pos = scores.indexOf(value);
        a[pos]++;
    }
    return a;
}

From source file:dk.statsbiblioteket.doms.licensemodule.solr.AbstractSolrJClient.java

public static String makeAuthIdPart(ArrayList<String> ids) {
    StringBuilder queryIdPart = new StringBuilder();
    queryIdPart.append("(");
    for (int i = 0; i < ids.size(); i++) {
        String id = ids.get(i);
        //Remove all \ and " from the string
        id = id.replaceAll("\\\\", "");
        id = id.replaceAll("\\\"", "");

        queryIdPart.append(filterField + ":\"" + id + "\"");
        if (i < ids.size() - 1) {
            queryIdPart.append(" OR ");
        }//from   w  ww .  j a v a 2  s .  co m
    }
    queryIdPart.append(")");
    return queryIdPart.toString();
}

From source file:Main.java

private static Bitmap buildBitmap(ArrayList<Bitmap> bitmaps) {
    if (bitmaps == null || bitmaps.size() == 0) {
        return null;
    }/*from  w w  w.j  a v  a 2s .co  m*/
    int width = 0;
    int height = 0;
    for (int i = 0; i < bitmaps.size(); i++) {
        width = width + bitmaps.get(i).getWidth();
        height = Math.max(height, bitmaps.get(i).getHeight());
    }
    Bitmap resultBitmap = Bitmap.createBitmap(width, height, Config.ARGB_4444);
    int drawWidth = 0;
    Canvas canvas = new Canvas(resultBitmap);
    for (int j = 0; j < bitmaps.size(); j++) {
        drawWidth = j * bitmaps.get(j).getWidth();
        canvas.drawBitmap(bitmaps.get(j), drawWidth, 0, null);
    }
    return resultBitmap;
}