List of usage examples for java.util ArrayList size
int size
To view the source code for java.util ArrayList size.
Click Source Link
From source file:Main.java
/** * returns an arrayList of codes that correspond to the array positions with * true values//from www . j a va2s .c om * * @return */ public static String[] getSelectedCodes(Context context, boolean[] selectedItems, int codeResourceId) { ArrayList<String> codes = new ArrayList<String>(); Resources res = context.getResources(); String[] allCodes = res.getStringArray(codeResourceId); for (int i = 0; i < selectedItems.length; i++) { if (selectedItems[i]) { codes.add(allCodes[i]); } } return codes.toArray(new String[codes.size()]); }
From source file:Estadistica.java
/** * Metodo calular el rango//from w w w.j a v a 2 s. com * 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))); }
From source file:edu.uci.ics.jung.algorithms.transformation.FoldingTransformer.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 w ww . j a v a2s . c o 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> Graph<E, F> foldHypergraphVertices(Hypergraph<V, E> h, Factory<Graph<E, F>> graph_factory, Factory<F> edge_factory) { Graph<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:GUI.WebBrowserPanel.java
public static boolean parseContent(ArrayList<String> content, c_Card card) { boolean foundCard = false; String line;/* ww w. j a va 2s .co m*/ for (int i = 0; i < content.size(); i++) { line = content.get(i); if (line.contains("multiverseid=") && card.MID == 0) { foundCard = true; card.MID = Integer.parseInt(str.middleOf("multiverseid=", line, "\" id=")); i += 300; /* help out the parser a little */ } else if (line.contains("Card Name:")) { i += 2; card.Name = str.leftOf(content.get(i), "</div>").trim(); } else if (line.contains("Mana Cost:")) { i += 2; line = content.get(i); String glyphs = ""; do { line = str.rightOf(line, "/Handlers/Image.ashx?size=medium&name="); glyphs += str.leftOf(line, "&type=symbol") + ","; } while (line.contains("/Handlers/Image.ashx?size=medium&name=")); card.CastingCost = new c_CastingCost(glyphs.substring(0, glyphs.length() - 1)); i += 5; /* skip over converted mana cost */ glyphs = null; } else if (line.contains("Types:")) { i += 2; line = content.get(i); if (line.contains("")) { card.Type = str.leftOf(line, "").trim(); card.SubType = str.middleOf(" ", line, "</div>"); } else { card.Type = str.leftOf(line, "</div>").trim(); card.SubType = ""; } } else if (line.contains("P/T:")) { i += 2; line = content.get(i); card.PT = str.leftOf(line, "</div>").replaceAll(" ", ""); } else if (line.contains("Expansion:")) { i += 4; line = content.get(i); card.Expansion = str.middleOf(">", line, "</a>"); break; /* nothing left of interest */ } } line = null; return foundCard; }
From source file:edu.uci.ics.jung.algorithms.transformation.FoldingTransformer.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. * /*w w w . j ava2s .com*/ * <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> Graph<V, E> foldHypergraphEdges(Hypergraph<V, E> h, Factory<Graph<V, E>> graph_factory, Factory<E> edge_factory) { Graph<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:edu.uci.ics.jung.algorithms.transformation.FoldingTransformerFixed.java
/** * @param target//from www . j a v a 2s . c om * @param e * @param incident */ private static <S, T> void populateTarget(UndirectedGraph<S, FoldedEdge<S, T>> target, T e, ArrayList<S> incident) { for (int i = 0; i < incident.size(); i++) { S v1 = incident.get(i); for (int j = i + 1; j < incident.size(); j++) { S v2 = incident.get(j); FoldedEdge<S, T> e_coll = target.findEdge(v1, v2); if (e_coll == null) { e_coll = new FoldedEdge<S, T>(v1, v2); target.addEdge(e_coll, v1, v2); } e_coll.getFolded().add(e); } } }
From source file:Main.java
/** * Maps a coorindate in a descendant view into the parent. *//* www.j av a 2 s. c o m*/ public static float mapCoordInDescendentToSelf(View descendant, View root, float[] coord, boolean includeRootScroll) { ArrayList<View> ancestorChain = new ArrayList<View>(); float[] pt = { coord[0], coord[1] }; View v = descendant; while (v != root && v != null) { ancestorChain.add(v); v = (View) v.getParent(); } ancestorChain.add(root); float scale = 1.0f; int count = ancestorChain.size(); for (int i = 0; i < count; i++) { View v0 = ancestorChain.get(i); // For TextViews, scroll has a meaning which relates to the text position // which is very strange... ignore the scroll. if (v0 != descendant || includeRootScroll) { pt[0] -= v0.getScrollX(); pt[1] -= v0.getScrollY(); } v0.getMatrix().mapPoints(pt); pt[0] += v0.getLeft(); pt[1] += v0.getTop(); scale *= v0.getScaleX(); } coord[0] = pt[0]; coord[1] = pt[1]; return scale; }
From source file:Main.java
/** * returns an arrayList of language codes that are active. * // w ww .j a v a2s .c o m * @param bs * @return */ public static String[] getSelectedLangCodes(Context context, int[] indexes, boolean[] selectedItems, int codeResourceId) { ArrayList<String> codes = new ArrayList<String>(); Resources res = context.getResources(); String[] allCodes = res.getStringArray(codeResourceId); for (int i = 0; i < indexes.length; i++) { if (selectedItems[i]) { codes.add(allCodes[indexes[i]]); } } return codes.toArray(new String[codes.size()]); }
From source file:Main.java
/** * Method allNodesByName./* w w w. j a va 2 s. com*/ * * @param node * @param nodeName * @return ArrayList * <p/> * Purpose: given a node & tag name, returns an ArrayList of ALL nodes that * have that tag. Useful when there are multiple nodes of the same. For * example, used to parse an entire XML document into an array of testcases. */ public static ArrayList allNodesByName(Node node, String nodeName) { ArrayList nodes = new ArrayList(); NodeList currNodes = node.getChildNodes(); int length = currNodes.getLength(); for (int i = 0; i < length; i++) { Node thisNode = currNodes.item(i); if (thisNode.getNodeName().equals(nodeName)) { nodes.add(thisNode); } } if (nodes.size() > 0) { return nodes; } else { return null; } }
From source file:io.jxcore.node.jxcore.java
public static void javaCall(ArrayList<Object> params) { if (params.size() < 2 || params.get(0).getClass() != String.class || params.get(params.size() - 1).getClass() != String.class) { Log.e(LOGTAG, "JavaCall recevied an unknown call"); return;//from ww w .j a v a 2 s . c om } String receiver = params.remove(0).toString(); String callId = params.remove(params.size() - 1).toString(); if (!java_callbacks.containsKey(receiver)) { Log.e(LOGTAG, "JavaCall recevied a call for unknown method " + receiver); return; } java_callbacks.get(receiver).Receiver(params, callId); }