List of usage examples for java.util ListIterator previous
E previous();
From source file:org.xchain.impl.FilterChainImpl.java
public boolean postProcess(JXPathContext context, Exception exception) { ListIterator<Command> iterator = popIterator(); boolean handled = false; boolean result = false; while (iterator.hasPrevious()) { Command previous = iterator.previous(); if (previous instanceof Filter) { try { result = ((Filter) previous).postProcess(context, exception); if (result) { handled = true;/*w w w .j av a 2s. c om*/ } } catch (Exception e) { // Silently ignore } } } return handled; }
From source file:br.com.esign.logistics.core.Route.java
public Route opposite() { if (routes == null || routes.isEmpty()) routes = Arrays.asList(new Route[] { this }); int size = routes.size(); if (size == 1) { return new Route(getDestination(), getOrigin(), getDistance()); } else {/* w w w . java 2 s . c o m*/ List<Route> oppositeRoutes = new ArrayList<>(size); ListIterator<Route> iterator = routes.listIterator(size); while (iterator.hasPrevious()) { oppositeRoutes.add(iterator.previous().opposite()); } return new Route(oppositeRoutes); } }
From source file:org.apache.openjpa.kernel.exps.CandidatePath.java
public FieldMetaData last() { if (_actions == null) return null; ListIterator itr = _actions.listIterator(_actions.size()); Object prev;/*from w ww . jav a2s . co m*/ while (itr.hasPrevious()) { prev = itr.previous(); if (prev instanceof Traversal) return ((Traversal) prev).field; } return null; }
From source file:com.nuodb.migrator.cli.parse.parser.ParserImpl.java
/** * Parse the withConnection.arguments according to the specified options and properties. * * @param arguments to parse./*from ww w . ja va 2s.com*/ * @param option sets the option to parse against. * @return the option setValue object. */ public OptionSet parse(String[] arguments, Option option) throws OptionException { if (logger.isTraceEnabled()) { logger.trace(format("Parsing options %s", join(asList(arguments), " "))); } List<String> list = Lists.newArrayList(arguments); CommandLine commandLine = new CommandLineImpl(option, list); // pick up any defaults from the meta option.defaults(commandLine); // withConnection the options as far as possible ListIterator<String> iterator = list.listIterator(); Object previous = null; while (option.canProcess(commandLine, iterator)) { // peek at the next item and backtrack String current = iterator.next(); iterator.previous(); // if we have just tried to process this instance if (current == previous) { // abort break; } previous = current; option.preProcess(commandLine, iterator); option.process(commandLine, iterator); } if (iterator.hasNext()) { throw new OptionException(format("Unexpected argument %s", iterator.next()), option); } option.postProcess(commandLine); return commandLine; }
From source file:org.hyperic.hq.measurement.galerts.ResourceMetricTracker.java
/** * If there are any newer (or with the same timestamp) tracked metrics than * this one that just came in, remove those newer tracked metrics. This * accounts for the backfilled case where the backfilled metrics reported * one value, but then the agent starts reporting again with the "real" * values that should preempt the backfilled values. * /* ww w . j a v a 2 s.c o m*/ * @param value The metric value that just came in. */ private void removeNewerTrackedMetrics(MetricValue value) { if (_chronOrderedValues.isEmpty()) { return; } if (value.getTimestamp() <= ((MetricValue) _chronOrderedValues.getLast()).getTimestamp()) { _log.debug("Removing tracked metrics newer than timestamp=" + value.getTimestamp()); ListIterator iter = _chronOrderedValues.listIterator(_chronOrderedValues.size()); while (iter.hasPrevious()) { MetricValue trackedValue = (MetricValue) iter.previous(); if (trackedValue.getTimestamp() >= value.getTimestamp()) { iter.remove(); } else { return; } } } }
From source file:com.bonsai.btcreceive.HDChain.java
private int marginSize() { int count = 0; ListIterator li = mAddrs.listIterator(mAddrs.size()); while (li.hasPrevious()) { HDAddress hda = (HDAddress) li.previous(); if (!hda.isUnused()) return count; ++count;/*w w w. j av a 2 s .c o m*/ } return count; }
From source file:org.apache.fop.layoutmgr.inline.FootnoteLayoutManager.java
/** * Find the last box in the sequence, and add a reference to the FootnoteBodyLM * @param citationList the list of elements representing the footnote citation *///w w w . j a v a2 s . c o m private void addAnchor(List citationList) { KnuthInlineBox lastBox = null; // the list of elements is searched backwards, until we find a box ListIterator citationIterator = citationList.listIterator(citationList.size()); while (citationIterator.hasPrevious() && lastBox == null) { Object obj = citationIterator.previous(); if (obj instanceof KnuthElement) { // obj is an element KnuthElement element = (KnuthElement) obj; if (element instanceof KnuthInlineBox) { lastBox = (KnuthInlineBox) element; } } else { // obj is a sequence of elements KnuthSequence seq = (KnuthSequence) obj; ListIterator nestedIterator = seq.listIterator(seq.size()); while (nestedIterator.hasPrevious() && lastBox == null) { KnuthElement element = (KnuthElement) nestedIterator.previous(); if (element instanceof KnuthInlineBox && !element.isAuxiliary() || element == forcedAnchor) { lastBox = (KnuthInlineBox) element; } } } } if (lastBox != null) { lastBox.setFootnoteBodyLM(bodyLM); } else { //throw new IllegalStateException("No anchor box was found for a footnote."); } }
From source file:org.apache.fop.render.ImageHandlerRegistry.java
/** * Add an image handler. The handler itself is inspected to find out what it supports. * @param handler the ImageHandler instance *//*from ww w . j a va 2 s . com*/ public synchronized void addHandler(ImageHandler handler) { Class<? extends Image> imageClass = handler.getSupportedImageClass(); //List this.handlers.put(imageClass, handler); //Sorted insert (sort by priority) ListIterator<ImageHandler> iter = this.handlerList.listIterator(); while (iter.hasNext()) { ImageHandler h = iter.next(); if (HANDLER_COMPARATOR.compare(handler, h) < 0) { iter.previous(); break; } } iter.add(handler); this.handlerRegistrations++; }
From source file:se.uu.it.cs.recsys.ruleminer.impl.FPGrowthImpl.java
private Map<Set<Integer>, Integer> miningWithFPGrowth(FPTree fpTree, Set<Integer> suffixPattern) { Map<Set<Integer>, Integer> frequentPatternFromSinglePrefixPath = new HashMap<>(); FPTree branchingTree = fpTree;/*from ww w. j a v a 2s . c o m*/ if (fpTree.hasSinglePrefixPath()) { List<Item> singlePrefixPath = fpTree.getSinglePrefixPathInTopDownOrder(); // LOGGER.debug("Single prefix path: {}", singlePrefixPath); Map<Set<Integer>, Integer> frequentPatternWithinSinglePrefixPath = getFrequentPatternFromSinglePrefixPath( singlePrefixPath); frequentPatternFromSinglePrefixPath = frequentPatternWithinSinglePrefixPath.entrySet().stream() .collect(Collectors.toMap(entry -> { Set<Integer> existingPattern = new HashSet<>(entry.getKey()); existingPattern.addAll(suffixPattern); return existingPattern; }, entry -> entry.getValue())); branchingTree = fpTree.getBranchingTree(); if (branchingTree == null) { return frequentPatternFromSinglePrefixPath; } } Map<Set<Integer>, Integer> frequentPatternFromBranchingTree = new HashMap<>(); List<HeaderTableItem> headerList = branchingTree.getHeaderTable(); ListIterator<HeaderTableItem> itr = headerList.listIterator(headerList.size()); while (itr.hasPrevious()) { HeaderTableItem visitingItem = itr.previous(); Set<Integer> newPattern = new HashSet<>(suffixPattern); newPattern.add(visitingItem.getItem().getId()); frequentPatternFromBranchingTree.put(newPattern, visitingItem.getItem().getCount()); // LOGGER.debug("Adding new pattern: {}, count: {}", newPattern, visitingItem.getItem().getCount()); Map<List<Integer>, Integer> patternBase = FPTreeUtil.getPatternBase(visitingItem); // LOGGER.debug("Pattern base for item {} is: {}", visitingItem.getItem(), patternBase); FPTree conditionalTree = FPTreeBuilder.buildConditionalFPTree(patternBase, this.minSupport); if (conditionalTree != null && !conditionalTree.getRoot().getChildren().isEmpty()) { frequentPatternFromBranchingTree.putAll(miningWithFPGrowth(conditionalTree, newPattern)); } } return consolidatePatterns(frequentPatternFromSinglePrefixPath, frequentPatternFromBranchingTree); }
From source file:fr.norad.visuwall.core.business.process.capabilities.BuildCapabilityProcess.java
public void updateLastNotBuildingId(Project project) throws ProjectNotFoundException { ListIterator<String> reverseBuildIt = project.getBuildId().listIterator(project.getBuildId().size()); while (reverseBuildIt.hasPrevious()) { String buildId = reverseBuildIt.previous(); Build build = getCreatedWithContentBuild(project, buildId); if (build.isBuilding()) { continue; }/*w ww . j a v a2 s . c om*/ project.setLastNotBuildingId(buildId); break; } }