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:fr.bmartel.android.tictactoe.request.ResponseParser.java
public static MessageObject parseMessage(Intent intent) { ArrayList<String> actionsStr = intent.getStringArrayListExtra(""); if (actionsStr.size() > 0) { try {//www. j a v a2s . co m JSONObject mainObject = new JSONObject(actionsStr.get(0)); if (mainObject.has(RequestConstants.DEVICE_MESSAGE_TOPIC)) { GameMessageTopic topic = GameMessageTopic .getTopic(mainObject.getInt(RequestConstants.DEVICE_MESSAGE_TOPIC)); switch (topic) { case CHALLENGED: { if (mainObject.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID) && mainObject.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)) { return new ChallengeMessage(topic, mainObject.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID), mainObject.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)); } return null; } case ACCEPTED: { if (mainObject.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID) && mainObject.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)) { return new ChallengeResponse(topic, true, mainObject.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID), mainObject.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)); } return null; } case DECLINED: { if (mainObject.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID) && mainObject.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)) { return new ChallengeResponse(topic, false, mainObject.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID), mainObject.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)); } return null; } case GAME_STOPPED: { break; } case PLAY: { if (mainObject.has(RequestConstants.DEVICE_PLAY)) { return new PlayRequest(topic, mainObject.getInt(RequestConstants.DEVICE_PLAY)); } return null; } case CLIENT_CONNECTED: { if (mainObject.has(RequestConstants.DEVICE_ID) && mainObject.has(RequestConstants.DEVICE_NAME)) { return new ClientConnectionEvent(topic, mainObject.getString(RequestConstants.DEVICE_ID), mainObject.getString(RequestConstants.DEVICE_NAME)); } return null; } } } } catch (JSONException e) { e.printStackTrace(); } } return null; }
From source file:lite.flow.util.ActivityInspector.java
static public String[] getOutputNames(Class<?> clazz) { ArrayList<Field> outputs = getOutputs(clazz); String[] outputNames = new String[outputs.size()]; for (int i = 0; i < outputNames.length; i++) { outputNames[i] = outputs.get(i).getName(); }/* ww w . j av a 2 s . c om*/ return outputNames; }
From source file:Main.java
public static String[] removeLocalUserNameFromArray(String[] user) { ArrayList<String> userList = new ArrayList<String>(); for (int i = 0; i < user.length; i++) { Log.d("i=" + i, user[i]); if (USER_NAME.equals(user[i]) == false) { userList.add(user[i]);/* w w w . ja v a2 s . c o m*/ } } String returnArray[] = new String[userList.size()]; for (int i = 0; i < returnArray.length; i++) { returnArray[i] = userList.get(i).toString(); } return returnArray; }
From source file:k_means.Plot.java
public static XYDataset createDataset(ArrayList<Data> dataSet, int k) { final XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < k; i++) { String str = "Cluster " + (i + 1); XYSeries cluster = new XYSeries(str); for (int j = 0; j < dataSet.size(); j++) { if (dataSet.get(j).getCluster() == i) { cluster.add(dataSet.get(j).getX(), dataSet.get(j).getY()); }/* w ww .j a v a2 s . c o m*/ } dataset.addSeries(cluster); } return dataset; }
From source file:Estadistica.java
/** * Metodo calcular el valor getTailArea - significancia * param un valor double y una lista de valores * @return el valor getTailArea/*from www.j a v a 2 s .co m*/ */ public static double getTailArea(double r, ArrayList<Double> arrayList) { double x = Math.abs(r) * Math.sqrt(arrayList.size() - 2) / Math.sqrt(1 - r * r); return 1 - 2 * cal(x, arrayList.size() - 2); }
From source file:Main.java
public static Element getElementByTagName(Element n, String elementName) { int sz = n.getChildNodes().getLength(); ArrayList<Element> elements = new ArrayList<Element>(sz); for (int idx = 0; idx < sz; idx++) { Node node = n.getChildNodes().item(idx); if (node instanceof Element && node.getLocalName().equals(elementName)) elements.add((Element) node); }/* ww w.j ava2 s .c om*/ if (elements.size() > 0) return elements.get(0); return null; }
From source file:net.metanotion.contentstore.markup.MarkupParser.java
private static ArrayList<Html> newPara(final Map<String, TagTransformer> transformers, final int brCt, ArrayList<Html> currentPara, final ArrayList<Html> output, final boolean allowBrs) { if ((currentPara.size() > 0) && (brCt > 0)) { if (brCt == 1) { if (allowBrs) { currentPara.add(_BR); } else { currentPara.add(new SafeString(" ")); }/*from ww w . j a v a 2 s . c om*/ } else { output.add(transform(transformers, new Tag("p").addAll(currentPara))); currentPara = new ArrayList<Html>(); } } return currentPara; }
From source file:ch.unil.genescore.vegas.LinkageDisequilibrium.java
static public DenseMatrix computeCorrelationMatrixMTJ(ArrayList<Snp> geneSnps) { DenseMatrix normalizedDataMat = loadGenotypeIntoDenseMatrix(geneSnps); DenseMatrix correlationMat = new DenseMatrix(geneSnps.size(), geneSnps.size()); double invNumberOfRows = 1.0 / ((double) normalizedDataMat.numRows()); normalizedDataMat.transAmult(invNumberOfRows, normalizedDataMat, correlationMat); return correlationMat; }
From source file:ch.unil.genescore.vegas.LinkageDisequilibrium.java
/** Compute correlation (LD) r values for the given snps (use snpCorrelation_ to avoid recomputing previous values) */ static public RealMatrix computeCorrelationMatrix(ArrayList<Snp> geneSnps) { // The correlation matrix for the given set of snps RealMatrix corr = MatrixUtils.createRealMatrix(geneSnps.size(), geneSnps.size()); // For each snp pair for (int i = 0; i < geneSnps.size(); i++) { for (int j = i + 1; j < geneSnps.size(); j++) { Snp snp_i = geneSnps.get(i); Snp snp_j = geneSnps.get(j); double r = computeCorrelation(snp_i, snp_j); corr.setEntry(i, j, r);/*from w w w. ja va 2 s. c om*/ corr.setEntry(j, i, r); } } // Set diagonal to 1 for (int i = 0; i < geneSnps.size(); i++) corr.setEntry(i, i, 1); return corr; }
From source file:lite.flow.util.ActivityInspector.java
static public EntryPoint[] getEntryPoints(Class<?> clazz) { EntryPoint[] entryPoints = getEntryAnnotatedMethods(clazz); if (entryPoints != null && entryPoints.length > 0) return entryPoints; ArrayList<Method> entryMethods = getEntryMethods(clazz); entryPoints = new EntryPoint[entryMethods.size()]; int i = 0;//from w ww . j a va2s .co m for (Method entryMethod : entryMethods) { String[] inputNames = getArgumentNames(entryMethod); EntryPoint entryPoint = new EntryPoint(entryMethod, inputNames, entryMethod.getName()); entryPoints[i++] = entryPoint; } return entryPoints; }