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:no.digipost.android.api.ContentOperations.java

public static Documents getAccountContentMetaDocument(Context context, int content,
        String oldestVisibleDocumentDate)
        throws DigipostApiException, DigipostClientException, DigipostAuthenticationException {

    getCurrentMailbox(context);//from  w w w  .j  av  a  2  s  .  c  o  m
    if (mailbox == null) {
        return null;
    }

    refreshApiAccess();

    if (oldestVisibleDocumentDate == null) {
        oldestVisibleDocumentDate = Long.toString(new Date().getTime());
    }

    MultivaluedMap params = new MultivaluedMapImpl();
    params.add(ApiConstants.GET_DOCUMENT_LASTSEEN, oldestVisibleDocumentDate);
    params.add(ApiConstants.GET_DOCUMENT_LIMIT, Integer.toString(ApiConstants.GET_DOCUMENT_LIMIT_N));

    if (content == ApplicationConstants.MAILBOX) {
        return (Documents) JSONUtilities.processJackson(Documents.class,
                apiAccess.getApiJsonString(context, mailbox.getInboxUri(), params));
    } else {
        content -= ApplicationConstants.numberOfStaticFolders;
        ArrayList<Folder> folders = mailbox.getFolders().getFolder();

        if (folders != null && content < folders.size()) {
            Folder folder = (Folder) JSONUtilities.processJackson(Folder.class,
                    apiAccess.getApiJsonString(context, folders.get(content).getSelfUri(), params));
            if (folder != null) {
                return folder.getDocuments();
            }
        }
    }
    return null;
}

From source file:com.piggate.sdk.PiggateOffers.java

private static void registryOffers(ArrayList<PiggateOffers> offers) {

    ArrayList<PiggateOffers> _new_registry = new ArrayList<PiggateOffers>();
    Date date = new Date();
    PiggateOffers offer;// w  w  w  . j  a v a2 s.c o m

    for (int x = 0; x < offers.size(); x++) { //Set the last call and put offers into internal_offers
        offer = offers.get(x);
        offer.setLastCall(date);
        int index = internal_offers.indexOf(offer);
        if (index >= 0) {
            internal_offers.remove(index);
        }
        internal_offers.add(offer);
    }
    //If the time since the last call to the offers until now is less than 35 seconds
    //put the offers into a new registry
    for (int x = 0; x < internal_offers.size(); x++) {
        offer = internal_offers.get(x);
        if (Piggate.getDateDiff(offer.getLastCall(), date, TimeUnit.SECONDS) <= 35) {
            _new_registry.add(offer);
        }
    }
    internal_offers = _new_registry;
}

From source file:cn.edu.xidian.repace.xml2hbase.filter.TestFilter.java

public static Filter createFilterFromArguments(ArrayList<byte[]> filterArguments) {
    Preconditions.checkArgument(filterArguments.size() == 4 || filterArguments.size() == 6,
            "Expected 4 or 6 but got: %s", filterArguments.size());
    byte[] family = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
    byte[] qualifier = ParseFilter.removeQuotesFromByteArray(filterArguments.get(1));
    CompareOp compareOp = ParseFilter.createCompareOp(filterArguments.get(2));
    WritableByteArrayComparable comparator = ParseFilter
            .createComparator(ParseFilter.removeQuotesFromByteArray(filterArguments.get(3)));

    if (comparator instanceof RegexStringComparator || comparator instanceof SubstringComparator) {
        if (compareOp != CompareOp.EQUAL && compareOp != CompareOp.NOT_EQUAL) {
            throw new IllegalArgumentException("A regexstring comparator and substring comparator "
                    + "can only be used with EQUAL and NOT_EQUAL");
        }//from   w  w w  .jav a  2 s  .  com
    }

    SingleColumnValueFilter filter = new SingleColumnValueFilter(family, qualifier, compareOp, comparator);

    if (filterArguments.size() == 6) {
        boolean filterIfMissing = ParseFilter.convertByteArrayToBoolean(filterArguments.get(4));
        boolean latestVersionOnly = ParseFilter.convertByteArrayToBoolean(filterArguments.get(5));
        filter.setFilterIfMissing(filterIfMissing);
        filter.setLatestVersionOnly(latestVersionOnly);
    }
    return filter;
}

From source file:edu.uci.ics.jung.algorithms.transformation.FoldingTransformerFixed.java

/**
 * Creates a <code>Graph</code> which is a vertex-folded version of <code>h</code>, whose
 * vertices are the input's hyperedges and whose edges are induced by adjacent hyperedges
 * in the input.//from ww w .j  a v  a2  s  .co m
 * 
 * <p>The vertices of the new graph are the same objects as the hyperedges of 
 * <code>h</code>, and <code>a</code> 
 * is connected to <code>b</code> in the new graph if the corresponding edges
 * in <code>h</code> have a vertex in common.  Thus, each vertex incident to  
 * <i>k</i> edges in <code>h</code> induces a <i>k</i>-clique in the new graph.</p>
 * 
 * <p>The edges of the new graph are created by the specified factory.</p>
 * 
 * @param <V> vertex type
 * @param <E> input edge type
 * @param <F> output edge type
 * @param h hypergraph to be folded
 * @param graph_factory factory used to generate the output graph
 * @param edge_factory factory used to generate the output edges
 * @return a transformation of the input graph whose vertices correspond to the input's hyperedges 
 * and edges are induced by hyperedges sharing vertices in the input
 */
public static <V, E, F> UndirectedGraph<E, F> foldHypergraphVertices(Hypergraph<V, E> h,
        Factory<UndirectedGraph<E, F>> graph_factory, Factory<F> edge_factory) {
    UndirectedGraph<E, F> target = graph_factory.create();

    for (E e : h.getEdges())
        target.addVertex(e);

    for (V v : h.getVertices()) {
        ArrayList<E> incident = new ArrayList<E>(h.getIncidentEdges(v));
        for (int i = 0; i < incident.size(); i++)
            for (int j = i + 1; j < incident.size(); j++)
                target.addEdge(edge_factory.create(), incident.get(i), incident.get(j));
    }

    return target;
}

From source file:mlflex.helper.MathUtilities.java

/** Calculates the minimum value from a list of numeric values.
 *
 * @param values List of numeric values/*from   w  w w.  j  a  va  2s . c  o m*/
 * @return Minimum value
 * @throws Exception
 */
public static double Min(ArrayList<Double> values) throws Exception {
    if (values.size() == 0)
        throw new Exception("The list was empty, so Min could not be determined.");

    int indexOfMin = 0;

    for (int i = 1; i < values.size(); i++) {
        Double value = values.get(i);

        if (value < values.get(indexOfMin))
            indexOfMin = i;
    }

    return values.get(indexOfMin);
}

From source file:bide.core.par.ParSpot.java

public static ParSpot[] init(double limDet, ArrayList<Spot> allSpots, ParGlobal gp, Likelihood li) {

    int n = allSpots.size();
    ParSpot[] allSp = new ParSpot[n];

    for (int i = 0; i < allSp.length; i++) {
        allSp[i] = new ParSpot(limDet, allSpots.get(i), gp, li, i);

    }//  www . j  a v  a 2 s  .co  m

    return allSp;
}

From source file:edu.uci.ics.jung.algorithms.transformation.FoldingTransformerFixed.java

/**
 * Creates a <code>Graph</code> which is an edge-folded version of <code>h</code>, where
 * hyperedges are replaced by k-cliques in the output graph.
 * //from   w w  w . j  av  a2  s . c  o m
 * <p>The vertices of the new graph are the same objects as the vertices of 
 * <code>h</code>, and <code>a</code> 
 * is connected to <code>b</code> in the new graph if the corresponding vertices
 * in <code>h</code> are connected by a hyperedge.  Thus, each hyperedge with 
 * <i>k</i> vertices in <code>h</code> induces a <i>k</i>-clique in the new graph.</p>
 * 
 * <p>The edges of the new graph are generated by the specified edge factory.</p>
 * 
 * @param <V> vertex type
 * @param <E> input edge type
 * @param h hypergraph to be folded
 * @param graph_factory factory used to generate the output graph
 * @param edge_factory factory used to create the new edges 
 * @return a copy of the input graph where hyperedges are replaced by cliques
 */
public static <V, E> UndirectedGraph<V, E> foldHypergraphEdges(Hypergraph<V, E> h,
        Factory<UndirectedGraph<V, E>> graph_factory, Factory<E> edge_factory) {
    UndirectedGraph<V, E> target = graph_factory.create();

    for (V v : h.getVertices())
        target.addVertex(v);

    for (E e : h.getEdges()) {
        ArrayList<V> incident = new ArrayList<V>(h.getIncidentVertices(e));
        for (int i = 0; i < incident.size(); i++)
            for (int j = i + 1; j < incident.size(); j++)
                target.addEdge(edge_factory.create(), incident.get(i), incident.get(j));
    }
    return target;
}

From source file:Main.java

public static boolean getFrequentElementBinary(int[] sample) {
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    ArrayList<Integer> count = new ArrayList<Integer>();
    ArrayList<Integer> uniId = new ArrayList<Integer>();
    int id = 0;//ww w.j a  va  2s  .c  om

    for (int col = 0; col < sample.length; col++) {
        // System.out.print(bcp[col] + "\t");
        int no = 0;
        if (!map.containsKey(sample[col])) {
            map.put(sample[col], id++);
            count.add(1);
            uniId.add(sample[col]);
        } else {
            no = map.get(sample[col]);
            count.set(no, count.get(no) + 1);
        }
    }

    int maximum = Integer.MIN_VALUE;
    int maxId = Integer.MIN_VALUE;
    for (int i = 0; i < count.size(); i++) {
        // System.out.print(uniId.get(i) + ":" + count.get(i) + ",\t");
        if (maximum < count.get(i)) {
            maximum = count.get(i);
            maxId = uniId.get(i);
        }
    }
    // System.out.println();

    map.clear();
    uniId.clear();
    count.clear();
    if (maxId == 1)
        return true;
    else
        return false;
}

From source file:com.nubits.nubot.trading.TradeUtils.java

public static ArrayList<Order> filterOrders(ArrayList<Order> originalList, String type) {
    ArrayList<Order> toRet = new ArrayList<>();
    for (int i = 0; i < originalList.size(); i++) {
        Order temp = originalList.get(i);
        if (temp.getType().equalsIgnoreCase(type)) {
            toRet.add(temp);/*from w ww.  ja  va  2  s . co m*/
        }
    }

    return toRet;
}

From source file:Estadistica.java

/**
 * Metodo calular el rango/*ww  w.  ja  v  a 2 s . c o  m*/
 * param  dos listas de valores, dos valores double double
 * @return rango
 */
public static double getRange(ArrayList<Double> xArrayList, ArrayList<Double> yArrayList, double b0, double b1,
        double xk) {
    double range = getX(0.35, xArrayList.size() - 2) * getSigma(xArrayList, yArrayList, b0, b1);
    ArrayList<Double> cal = new ArrayList<Double>();
    for (int i = 0; i < xArrayList.size(); i++) {
        cal.add(xArrayList.get(i) - getAverage(xArrayList));
    }
    return range * Math.sqrt(1 + (1.0 / xArrayList.size())
            + ((xk - getAverage(xArrayList)) * (xk - getAverage(xArrayList)) / multiple(cal, cal)));
}