List of usage examples for java.util LinkedList size
int size
To view the source code for java.util LinkedList size.
Click Source Link
From source file:com.edsoft.teknosaproject.bean.TreeNodeBean.java
private void rec(List<TreeNode> children, LinkedList<File> fileList, int i, File parent, TreeNode root) { if (i == fileList.size()) { return;// w w w.ja v a 2s . com } File file = fileList.get(i); TreeNode node; if (file.getParentFile().equals(parent)) { node = new DefaultTreeNode(file.getName()); children.add(node); if (!fileList.get(i).isFile()) { i++; rec(node.getChildren(), fileList, i, file, node); } else { i++; rec(node.getParent().getChildren(), fileList, i, file.getParentFile(), node.getParent()); } } else { node = root; file = parent; rec(node.getParent().getChildren(), fileList, i, file.getParentFile(), node.getParent()); } }
From source file:net.relet.freimap.NodeInfo.java
public void setLinkCountProfile(LinkedList<LinkCount> lcp) { if (lcp.size() == 0) { minLinks = 0;//from w w w .j a v a2s .c o m maxLinks = 0; return; } XYSeries data = new XYSeries("links"); XYSeries avail = new XYSeries("avail"); XYSeriesCollection datac = new XYSeriesCollection(data); datac.addSeries(avail); linkCountChart = ChartFactory.createXYLineChart("average incoming link count\r\nincoming link availability", "time", "count", datac, PlotOrientation.VERTICAL, false, false, false); sexupLayout(linkCountChart); long first = lcp.getFirst().time, last = lcp.getLast().time, lastClock = first, count = 0, maxCount = 0; long aggregate = (last - first) / CHART_WIDTH; double sum = 0; /* ok, this ain't effective, we do it just to pre-calculate maxCount */ ListIterator<LinkCount> li = lcp.listIterator(); while (li.hasNext()) { LinkCount lc = li.next(); count++; if (lc.time - lastClock > aggregate) { if (maxCount < count) maxCount = count; lastClock = lc.time; count = 0; } } //reset for second iteration count = 0; lastClock = first; //iterate again li = lcp.listIterator(); while (li.hasNext()) { LinkCount lc = li.next(); if (minLinks > lc.count) minLinks = lc.count; if (maxLinks < lc.count) maxLinks = lc.count; sum += lc.count; count++; if (aggregate == 0) aggregate = 1000;//dirty hack if (lc.time - lastClock > aggregate) { for (long i = lastClock; i < lc.time - aggregate; i += aggregate) { data.add(i * 1000, (i == lastClock) ? sum / count : Double.NaN); avail.add(i * 1000, (i == lastClock) ? ((double) count / maxCount) : 0); } count = 0; sum = 0; lastClock = lc.time; } } status = STATUS_AVAILABLE; }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.EliminateSubplanRule.java
private void elimSubplanOverEts(Mutable<ILogicalOperator> opRef, IOptimizationContext ctx) throws AlgebricksException { SubplanOperator subplan = (SubplanOperator) opRef.getValue(); for (ILogicalPlan p : subplan.getNestedPlans()) { for (Mutable<ILogicalOperator> r : p.getRoots()) { OperatorManipulationUtil.ntsToEts(r, ctx); }//from w w w .ja v a2 s.c o m } LinkedList<Mutable<ILogicalOperator>> allRoots = subplan.allRootsInReverseOrder(); if (allRoots.size() == 1) { opRef.setValue(allRoots.get(0).getValue()); } else { ILogicalOperator topOp = null; for (Mutable<ILogicalOperator> r : allRoots) { if (topOp == null) { topOp = r.getValue(); } else { LeftOuterJoinOperator j = new LeftOuterJoinOperator( new MutableObject<ILogicalExpression>(ConstantExpression.TRUE)); j.getInputs().add(new MutableObject<ILogicalOperator>(topOp)); j.getInputs().add(r); ctx.setOutputTypeEnvironment(j, j.computeOutputTypeEnvironment(ctx)); topOp = j; } } opRef.setValue(topOp); } }
From source file:com.ibm.bi.dml.runtime.controlprogram.parfor.mqo.PiggybackingWorker.java
/** * //from ww w . j a v a 2 s. co m * @param ids * @param results */ protected synchronized void putJobResults(LinkedList<Long> ids, LinkedList<JobReturn> results) { //make job returns available for (int i = 0; i < ids.size(); i++) _results.put(ids.get(i), results.get(i)); //notify all waiting threads notifyAll(); }
From source file:net.sf.markov4jmeter.testplangenerator.transformation.filters.AbstractFilter.java
/** * Searches for a (unique) occurrence of an element of certain type in a * given Test Plan. If no matching element is available, an error message * will be given; in case more than one element is available, the first * match will be used, and a warning message will be given. * * @param testPlan Test Plan to be explored. * @param type type of element to be searched for. * * @return/*from w ww . ja v a2s .co m*/ * a valid element, or <code>null</code> if no element is available. */ protected <T extends AbstractTestElement> T findUniqueTestPlanElement(final ListedHashTree testPlan, final Class<T> type) { final LinkedList<T> elements = this.testPlanModifier.collectElementsByType(testPlan, type); final int n = elements.size(); T element = null; if (n == 0) { final String message = String.format(AbstractFilter.ERROR_ELEMENT_NOT_FOUND, type); AbstractFilter.LOG.error(message); } else { if (n > 1) { final String message = String.format(AbstractFilter.WARNING_ELEMENT_NOT_UNIQUE, type); AbstractFilter.LOG.warn(message); } element = elements.getFirst(); } return element; }
From source file:org.objectrepository.instruction.InstructionAutocreateService.java
/** * objid/*from w ww . j a v a2 s .c o m*/ * * Add an object ID based on the folder structure: * /a/b/c/d becomes [na]/a.b.c.d * * @param instruction * @param stagingfileType */ private void objid(InstructionType instruction, StagingfileType stagingfileType) { if (instruction.getObjid() == null) { LinkedList list = new LinkedList(Arrays.asList(stagingfileType.getLocation().split("/"))); list.remove(list.size() - 1); list.remove(0); String objid = instruction.getNa() + "/" + StringUtils.join(list, '.'); stagingfileType.setObjid(objid); } }
From source file:com.jnj.b2b.core.search.solrfacetsearch.provider.entity.VariantValueCategoryModelPriorityComparator.java
@Override public int compare(final VariantValueCategoryModel variantValueCategory1, final VariantValueCategoryModel variantValueCategory2) { final LinkedList<CategoryModel> pathToRoot1 = getPathToRoot(variantValueCategory1); final LinkedList<CategoryModel> pathToRoot2 = getPathToRoot(variantValueCategory2); return Integer.compare(pathToRoot1.size(), pathToRoot2.size()); }
From source file:com.newlandframework.avatarmq.core.SendMessageCache.java
public void parallelDispatch(LinkedList<MessageDispatchTask> list) { List<Callable<Void>> tasks = new ArrayList<Callable<Void>>(); int startPosition = 0; Pair<Integer, Integer> pair = calculateBlocks(list.size(), list.size()); int numberOfThreads = pair.getRight(); int blocks = pair.getLeft(); for (int i = 0; i < numberOfThreads; i++) { MessageDispatchTask[] task = new MessageDispatchTask[blocks]; phaser.register();/*from www . j a v a 2 s . c o m*/ System.arraycopy(list.toArray(), startPosition, task, 0, blocks); tasks.add(new SendMessageTask(phaser, task)); startPosition += blocks; } ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads); for (Callable<Void> element : tasks) { executor.submit(element); } }
From source file:core.Helpers.java
public String[] getApplicants() { String[] dataformats = { "asdp", "jpeg" }; LinkedList<File> j = (LinkedList<File>) FileUtils.listFiles(new File("applicants"), dataformats, false); String[] al = new String[j.size()]; for (int i = 0; i < j.size(); i++) { al[i] = (j.get(i).getName().toString().replace(".asdp", "")); }//from ww w . j av a2 s . c om return al; }
From source file:pl.exsio.ca.app.report.terraincard.view.TerrainCardsView.java
@Override protected void buildPdfDocument(Map<String, Object> map, Document dcmnt, PdfWriter writer, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception { LinkedList<TerrainCardPage> pages = this.viewModel.getPages(map); int pagesCount = pages.size(); for (int i = 0; i < pagesCount; i++) { dcmnt.add(this.getHeader(map)); dcmnt.add(this.buildTable(pages.get(i))); dcmnt.add(this.getCreationDate(new Date())); dcmnt.add(this.getPageCounter(pagesCount, i + 1)); if (i < pages.size() - 1) { dcmnt.newPage();/*from w w w . j av a2 s . c o m*/ } } }