List of usage examples for java.util List clear
void clear();
From source file:com.cdd.bao.template.ClipboardSchema.java
private static void formatGroupTSV(List<String> lines, Schema.Group group) { List<String> cols = new ArrayList<>(); cols.add(group.name);//from www. ja v a 2 s .c o m cols.add(group.descr.replace("\n", " ")); cols.add(""); for (String g : group.groupNest()) cols.add(g); cols.add(Util.safeString(group.groupURI)); lines.add(String.join("\t", cols)); for (Schema.Assignment assn : group.assignments) { cols.clear(); cols.add(assn.name); cols.add(assn.descr.replace("\n", " ")); cols.add(assn.propURI); for (String g : assn.groupNest()) cols.add(g); lines.add(String.join("\t", cols)); } for (Schema.Group subgrp : group.subGroups) formatGroupTSV(lines, subgrp); }
From source file:joinery.impl.Aggregation.java
public static <V> DataFrame<Number> cov(final DataFrame<V> df) { DataFrame<Number> num = df.numeric(); StorelessCovariance cov = new StorelessCovariance(num.size()); // row-wise copy to double array and increment double[] data = new double[num.size()]; for (List<Number> row : num) { for (int i = 0; i < row.size(); i++) { data[i] = row.get(i).doubleValue(); }/*from w w w . j a v a 2 s . co m*/ cov.increment(data); } // row-wise copy results into new data frame double[][] result = cov.getData(); DataFrame<Number> r = new DataFrame<>(num.columns()); List<Number> row = new ArrayList<>(num.size()); for (int i = 0; i < result.length; i++) { row.clear(); for (int j = 0; j < result[i].length; j++) { row.add(result[i][j]); } r.append(row); } return r; }
From source file:com.hangum.tadpole.engine.sql.util.export.CSVExpoter.java
/** * make content//from w w w . ja v a2 s . c o m * * @param tableName * @param rsDAO * @param intLimitCnt * @return */ public static String makeContent(boolean isAddHead, String tableName, QueryExecuteResultDTO rsDAO, char seprator, int intLimitCnt) throws Exception { StringBuffer sbReturn = new StringBuffer(); List<Map<Integer, Object>> dataList = rsDAO.getDataList().getData(); List<String[]> listCsvData = new ArrayList<String[]>(); String[] strArrys = null; if (isAddHead) { // column . Map<Integer, String> mapLabelName = rsDAO.getColumnLabelName(); strArrys = new String[mapLabelName.size() - 1]; for (int i = 1; i < mapLabelName.size(); i++) { strArrys[i - 1] = mapLabelName.get(i); } listCsvData.add(strArrys); String strTitle = CSVFileUtils.makeData(listCsvData, seprator); sbReturn.append(strTitle); } listCsvData.clear(); // data for (int i = 0; i < dataList.size(); i++) { Map<Integer, Object> mapColumns = dataList.get(i); strArrys = new String[mapColumns.size() - 1]; for (int j = 1; j < mapColumns.size(); j++) { strArrys[j - 1] = mapColumns.get(j) == null ? "" : "" + mapColumns.get(j); //$NON-NLS-1$ } listCsvData.add(strArrys); sbReturn.append(CSVFileUtils.makeData(listCsvData, seprator)); listCsvData.clear(); if (intLimitCnt == i) break; } return sbReturn.toString(); }
From source file:com.aionemu.gameserver.services.toypet.PetFeedCalculator.java
public static PetFeedResult getReward(int fullCount, PetRewards rewardGroup, PetFeedProgress progress, int playerLevel) { if (progress.getHungryLevel() != PetHungryLevel.FULL || rewardGroup.getResults().size() == 0) { return null; }//from w w w . j a va 2s .c om int pointsIndex = ArrayUtils.indexOf(fullCounts, (short) fullCount); if (pointsIndex == ArrayUtils.INDEX_NOT_FOUND) { return null; } if (progress.isLovedFeeded()) { // for cash feed if (rewardGroup.getResults().size() == 1) { return rewardGroup.getResults().get(0); } List<PetFeedResult> validRewards = new ArrayList<PetFeedResult>(); int maxLevel = 0; for (PetFeedResult result : rewardGroup.getResults()) { int resultLevel = DataManager.ITEM_DATA.getItemTemplate(result.getItem()).getLevel(); if (resultLevel > playerLevel) { continue; } if (resultLevel > maxLevel) { maxLevel = resultLevel; validRewards.clear(); } validRewards.add(result); } if (validRewards.size() == 0) { return null; } if (validRewards.size() == 1) { return validRewards.get(0); } return validRewards.get(Rnd.get(validRewards.size())); } int rewardIndex = 0; int totalRewards = rewardGroup.getResults().size(); for (int row = 1; row < pointValues.length; row++) { int[] points = pointValues[row]; if (points[pointsIndex] <= progress.getTotalPoints()) { rewardIndex = Math.round((float) totalRewards / (pointValues.length - 1) * row) - 1; } } // Fix rounding discrepancy if (rewardIndex < 0) { rewardIndex = 0; } else if (rewardIndex > rewardGroup.getResults().size() - 1) { rewardIndex = rewardGroup.getResults().size() - 1; } return rewardGroup.getResults().get(rewardIndex); }
From source file:gov.sfmta.sfpark.MainScreenActivity.java
public static void updateMap() { if (mapView == null) { return;//w w w. j a va 2 s. c om } List<Overlay> mapOverlays = mapView.getOverlays(); mapOverlays.clear(); if (showPrice) { if (pricingAnnotationsOverlay != null) { mapOverlays.add(pricingAnnotationsOverlay); } } else { if (availabilityAnnotationsOverlay != null) { mapOverlays.add(availabilityAnnotationsOverlay); } } if (mBlueDot == null) mBlueDot = new MyLocationOverlay(mapView.getContext(), mapView); mBlueDot.enableMyLocation(); mapOverlays.add(mBlueDot); mapView.invalidate(); }
From source file:edu.uci.ics.asterix.event.service.AsterixEventServiceUtil.java
public static void poulateClusterEnvironmentProperties(Cluster cluster, String ccJavaOpts, String ncJavaOpts) { List<Property> clusterProperties = null; if (cluster.getEnv() != null && cluster.getEnv().getProperty() != null) { clusterProperties = cluster.getEnv().getProperty(); clusterProperties.clear(); } else {// ww w . j a va 2 s. c om clusterProperties = new ArrayList<Property>(); } clusterProperties.add(new Property(EventUtil.CC_JAVA_OPTS, ccJavaOpts)); clusterProperties.add(new Property(EventUtil.NC_JAVA_OPTS, ncJavaOpts)); clusterProperties .add(new Property("ASTERIX_HOME", cluster.getWorkingDir().getDir() + File.separator + "asterix")); clusterProperties.add(new Property("LOG_DIR", cluster.getLogDir())); clusterProperties.add(new Property("JAVA_HOME", cluster.getJavaHome())); clusterProperties.add(new Property("WORKING_DIR", cluster.getWorkingDir().getDir())); clusterProperties.add(new Property("CLIENT_NET_IP", cluster.getMasterNode().getClientIp())); clusterProperties.add(new Property("CLUSTER_NET_IP", cluster.getMasterNode().getClusterIp())); int clusterNetPort = cluster.getMasterNode().getClusterPort() != null ? cluster.getMasterNode().getClusterPort().intValue() : CLUSTER_NET_PORT_DEFAULT; int clientNetPort = cluster.getMasterNode().getClientPort() != null ? cluster.getMasterNode().getClientPort().intValue() : CLIENT_NET_PORT_DEFAULT; int httpPort = cluster.getMasterNode().getHttpPort() != null ? cluster.getMasterNode().getHttpPort().intValue() : HTTP_PORT_DEFAULT; clusterProperties.add(new Property("CLIENT_NET_PORT", "" + clientNetPort)); clusterProperties.add(new Property("CLUSTER_NET_PORT", "" + clusterNetPort)); clusterProperties.add(new Property("HTTP_PORT", "" + httpPort)); cluster.setEnv(new Env(clusterProperties)); }
From source file:com.espertech.esper.regression.pattern.TestFollowedByMaxEnginePool.java
private static void assertContextStatement(EPServiceProvider epService, EPStatement stmt, List<ConditionHandlerContext> contexts, int max) { assertEquals(1, contexts.size());/* www . jav a 2s . c o m*/ ConditionHandlerContext context = contexts.get(0); assertEquals(epService.getURI(), context.getEngineURI()); assertEquals(stmt.getText(), context.getEpl()); assertEquals(stmt.getName(), context.getStatementName()); ConditionPatternSubexpressionMax condition = (ConditionPatternSubexpressionMax) context .getEngineCondition(); assertEquals(max, condition.getMax()); contexts.clear(); }
From source file:com.espertech.esper.epl.lookup.EventTableIndexUtil.java
private static Pair<IndexMultiKey, EventTableIndexEntryBase> getBestCandidate( Map<IndexMultiKey, EventTableIndexEntryBase> indexCandidates) { // take the table that has a unique index List<IndexMultiKey> indexes = new ArrayList<IndexMultiKey>(); for (Map.Entry<IndexMultiKey, EventTableIndexEntryBase> entry : indexCandidates.entrySet()) { if (entry.getKey().isUnique()) { indexes.add(entry.getKey()); }//from w ww . j a v a 2 s .co m } if (!indexes.isEmpty()) { Collections.sort(indexes, INDEX_COMPARATOR_INSTANCE); return getPair(indexCandidates, indexes.get(0)); } // take the best available table indexes.clear(); indexes.addAll(indexCandidates.keySet()); if (indexes.size() > 1) { Collections.sort(indexes, INDEX_COMPARATOR_INSTANCE); } return getPair(indexCandidates, indexes.get(0)); }
From source file:com.hangum.tadpole.engine.sql.util.export.CSVExpoter.java
/** * csv ?? ? ? ?.//from ww w. j a va2s . c om * * @param tableName * @param rsDAO * @param seprator * @return ? * * @throws Exception */ public static String makeCSVFile(boolean isAddHead, String tableName, QueryExecuteResultDTO rsDAO, char seprator) throws Exception { String strTmpDir = PublicTadpoleDefine.TEMP_DIR + tableName + System.currentTimeMillis() + PublicTadpoleDefine.DIR_SEPARATOR; String strFile = tableName + ".csv"; String strFullPath = strTmpDir + strFile; // add bom character // ByteArrayOutputStream out = new ByteArrayOutputStream(); // //Add BOM characters // out.write(0xEF); // out.write(0xBB); // out.write(0xBF); // out.write(csvData.getBytes("UTF-8")); FileUtils.writeByteArrayToFile(new File(strFullPath), (new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF }), true); List<Map<Integer, Object>> dataList = rsDAO.getDataList().getData(); List<String[]> listCsvData = new ArrayList<String[]>(); String[] strArrys = null; if (isAddHead) { // column . Map<Integer, String> mapLabelName = rsDAO.getColumnLabelName(); strArrys = new String[mapLabelName.size() - 1]; for (int i = 1; i < mapLabelName.size(); i++) { strArrys[i - 1] = mapLabelName.get(i); } listCsvData.add(strArrys); String strTitle = CSVFileUtils.makeData(listCsvData, seprator); FileUtils.writeStringToFile(new File(strFullPath), strTitle, true); listCsvData.clear(); } // data for (int i = 0; i < dataList.size(); i++) { Map<Integer, Object> mapColumns = dataList.get(i); strArrys = new String[mapColumns.size() - 1]; for (int j = 1; j < mapColumns.size(); j++) { strArrys[j - 1] = mapColumns.get(j) == null ? "" : "" + mapColumns.get(j); //$NON-NLS-1$ } listCsvData.add(strArrys); if ((i % DATA_COUNT) == 0) { FileUtils.writeStringToFile(new File(strFullPath), CSVFileUtils.makeData(listCsvData, seprator), true); listCsvData.clear(); } } // ?. if (!listCsvData.isEmpty()) { FileUtils.writeStringToFile(new File(strFullPath), CSVFileUtils.makeData(listCsvData, seprator), true); } return strFullPath; }
From source file:annis.visualizers.component.grid.EventExtractor.java
/** * Returns the annotations to display according to the mappings configuration. * * This will check the "annos" and "annos_regex" paramters for determining. * the annotations to display. It also iterates over all nodes of the graph * matching the type.//from w w w .j a v a 2 s . c o m * * @param input The input for the visualizer. * @param type Which type of nodes to include * @return */ public static List<String> computeDisplayAnnotations(VisualizerInput input, Class<? extends SNode> type) { if (input == null) { return new LinkedList<String>(); } SDocumentGraph graph = input.getDocument().getSDocumentGraph(); Set<String> annoPool = getAnnotationLevelSet(graph, input.getNamespace(), type); List<String> annos = new LinkedList<String>(annoPool); String annosConfiguration = input.getMappings().getProperty(MAPPING_ANNOS_KEY); if (annosConfiguration != null && annosConfiguration.trim().length() > 0) { String[] split = annosConfiguration.split(","); annos.clear(); for (String s : split) { s = s.trim(); // is regular expression? if (s.startsWith("/") && s.endsWith("/")) { // go over all remaining items in our pool of all annotations and // check if they match Pattern regex = Pattern.compile(StringUtils.strip(s, "/")); LinkedList<String> matchingAnnos = new LinkedList<String>(); for (String a : annoPool) { if (regex.matcher(a).matches()) { matchingAnnos.add(a); } } annos.addAll(matchingAnnos); annoPool.removeAll(matchingAnnos); } else { annos.add(s); annoPool.remove(s); } } } // filter already found annotation names by regular expression // if this was given as mapping String regexFilterRaw = input.getMappings().getProperty(MAPPING_ANNO_REGEX_KEY); if (regexFilterRaw != null) { try { Pattern regexFilter = Pattern.compile(regexFilterRaw); ListIterator<String> itAnnos = annos.listIterator(); while (itAnnos.hasNext()) { String a = itAnnos.next(); // remove entry if not matching if (!regexFilter.matcher(a).matches()) { itAnnos.remove(); } } } catch (PatternSyntaxException ex) { log.warn("invalid regular expression in mapping for grid visualizer", ex); } } return annos; }