List of usage examples for java.util Queue remove
E remove();
From source file:com.baidu.rigel.biplatform.ac.util.DataModelUtils.java
/** * DataModel??//from ww w . j ava2 s. c o m * * @param dataModel DataModel * @throws IllegalAccessException */ private static void buildSortSummary(DataModel dataModel) throws IllegalAccessException { List<HeadField> rowLeafs = getLeafNodeList(dataModel.getRowHeadFields()); if (CollectionUtils.isNotEmpty(rowLeafs)) { if (dataModel.getOperateIndex() > rowLeafs.get(0).getCompareDatas().size()) { throw new IllegalAccessException("can not access operate index:" + dataModel.getOperateIndex()); } for (HeadField rowHeadField : dataModel.getRowHeadFields()) { List<HeadField> leafFileds = rowHeadField.getLeafFileds(true); if (CollectionUtils.isNotEmpty(leafFileds)) { Queue<HeadField> queue = new LinkedList<HeadField>(leafFileds); while (!queue.isEmpty()) { HeadField leafFiled = queue.remove(); if (CollectionUtils.isNotEmpty(leafFiled.getCompareDatas())) { leafFiled .setSummarizeData(leafFiled.getCompareDatas().get(dataModel.getOperateIndex())); } HeadField parent = null; if (leafFiled.getParent() != null) { parent = leafFiled.getParent(); } else if (leafFiled.getParentLevelField() != null) { parent = leafFiled.getParentLevelField(); if (!queue.contains(parent)) { queue.add(parent); } } if (parent != null && CollectionUtils.isEmpty(parent.getCompareDatas())) { parent.setSummarizeData(BigDecimalUtils.addBigDecimal(parent.getSummarizeData(), leafFiled.getSummarizeData())); } } } } } }
From source file:io.syndesis.project.converter.visitor.StepVisitorContext.java
default StepVisitorContext next() { final int index = getIndex(); final Queue<Step> remaining = getRemaining(); final Step next = remaining.remove(); return new StepVisitorContext.Builder().createFrom(this).index(index + 1).step(next).remaining(remaining) .build();//from w w w . jav a 2 s .co m }
From source file:org.opentestsystem.airose.docquality.processors.PassiveSentencesQualityProcessor.java
private boolean checkPassive(AbstractDocument doc, Parse p) { Queue<Parse> queue = new LinkedList<Parse>(); queue.add(p);// w w w . jav a 2 s .c o m while (queue.size() > 0) { p = queue.remove(); String parseType = p.getType(); if ((parseType.length() >= 2) && StringUtils.equalsIgnoreCase(parseType.substring(0, 2), "VB")) { String word = p.getText().substring(p.getSpan().getStart(), p.getSpan().getStart() + p.getSpan().length()); List<String> roots = wordnet.getBaseWords(word, EnumPOS.VERB); if ((roots.size() > 0) && (StringUtils.endsWithIgnoreCase(roots.get(0), "be"))) { return true; } else return false; } else { for (Parse child : p.getChildren()) queue.add(child); } } return false; }
From source file:org.wicketopia.mapping.ClassBasedTypeMapping.java
public String getTypeName(Class<?> propertyType) { final Queue<Class<?>> typeQueue = createTypeQueue(propertyType); while (!typeQueue.isEmpty()) { Class<?> type = typeQueue.remove(); final String editorType = typeMap.get(type.getName()); if (editorType != null) { return editorType; }//from ww w . j av a2 s .c o m } return defaultType; }
From source file:com.android.repository.util.InstallerUtil.java
/** * Compute the complete list of packages that need to be installed to meet the dependencies of * the given list (including the requested packages themselves, if they are not already * installed). Returns {@code null} if we were unable to compute a complete list of dependencies * due to not being able to find required packages of the specified version. * * Packages are returned in install order (that is, if we request A which depends on B, the * result will be [B, A]). If a dependency cycle is encountered the order of the returned * results at or below the cycle is undefined. For example if we have A -> [B, C], B -> D, and D * -> B then the returned list will be either [B, D, C, A] or [D, B, C, A]. * * Note that we assume installed packages already have their dependencies met. */// w ww. ja va 2 s . c o m @Nullable public static List<RemotePackage> computeRequiredPackages(@NonNull Collection<RemotePackage> requests, @NonNull RepositoryPackages packages, @NonNull ProgressIndicator logger) { Set<RemotePackage> requiredPackages = Sets.newHashSet(); Map<String, UpdatablePackage> consolidatedPackages = packages.getConsolidatedPkgs(); Set<String> seen = Sets.newHashSet(); Multimap<String, Dependency> allDependencies = HashMultimap.create(); Set<RemotePackage> roots = Sets.newHashSet(); Queue<RemotePackage> current = Lists.newLinkedList(); for (RemotePackage request : requests) { UpdatablePackage updatable = consolidatedPackages.get(request.getPath()); if (updatable == null) { logger.logWarning(String.format("No package with key %s found!", request.getPath())); return null; } if (!updatable.hasLocal() || updatable.isUpdate()) { current.add(request); roots.add(request); requiredPackages.add(request); seen.add(request.getPath()); } } while (!current.isEmpty()) { RemotePackage currentPackage = current.remove(); Collection<Dependency> currentDependencies = currentPackage.getAllDependencies(); for (Dependency d : currentDependencies) { String dependencyPath = d.getPath(); UpdatablePackage updatableDependency = consolidatedPackages.get(dependencyPath); if (updatableDependency == null) { logger.logWarning(String.format("Dependant package with key %s not found!", dependencyPath)); return null; } LocalPackage localDependency = updatableDependency.getLocal(); Revision requiredMinRevision = null; RevisionType r = d.getMinRevision(); if (r != null) { requiredMinRevision = r.toRevision(); } if (localDependency != null && (requiredMinRevision == null || requiredMinRevision.compareTo(localDependency.getVersion()) <= 0)) { continue; } if (seen.contains(dependencyPath)) { allDependencies.put(dependencyPath, d); continue; } seen.add(dependencyPath); RemotePackage remoteDependency = updatableDependency.getRemote(); if (remoteDependency == null || (requiredMinRevision != null && requiredMinRevision.compareTo(remoteDependency.getVersion()) > 0)) { logger.logWarning(String.format("Package \"%1$s\" with revision at least %2$s not available.", updatableDependency.getRepresentative().getDisplayName(), requiredMinRevision)); return null; } requiredPackages.add(remoteDependency); allDependencies.put(dependencyPath, d); current.add(remoteDependency); // We had a dependency on it, so it can't be a root. roots.remove(remoteDependency); } } List<RemotePackage> result = Lists.newArrayList(); while (!roots.isEmpty()) { RemotePackage root = roots.iterator().next(); roots.remove(root); result.add(root); for (Dependency d : root.getAllDependencies()) { Collection<Dependency> nodeDeps = allDependencies.get(d.getPath()); if (nodeDeps.size() == 1) { UpdatablePackage newRoot = consolidatedPackages.get(d.getPath()); if (newRoot == null) { logger.logWarning(String.format("Package with key %s not found!", d.getPath())); return null; } roots.add(newRoot.getRemote()); } nodeDeps.remove(d); } } if (result.size() != requiredPackages.size()) { logger.logInfo("Failed to sort dependencies, returning partially-sorted list."); for (RemotePackage p : result) { requiredPackages.remove(p); } result.addAll(requiredPackages); } return Lists.reverse(result); }
From source file:org.intellij.erlang.psi.impl.ErlangPsiImplUtil.java
private static boolean processDeclarationRecursive(ErlangCompositeElement o, PsiScopeProcessor processor, ResolveState state) {// w ww. ja va 2 s .co m Queue<ErlangCompositeElement> queue = new LinkedList<ErlangCompositeElement>(); queue.add(o); while (!queue.isEmpty()) { ErlangCompositeElement top = queue.remove(); if (!processor.execute(top, state)) return false; queue.addAll(PsiTreeUtil.getChildrenOfTypeAsList(top, ErlangCompositeElement.class)); } return true; }
From source file:org.openmrs.module.kenyaemr.converter.StringToRegimenConverter.java
/** * @see org.springframework.core.convert.converter.Converter#convert(Object) *//* w ww .j av a2s . c o m*/ @Override public Regimen convert(String source) { String[] tokens = source.split("\\|", -1); Queue<String> tokenQueue = new LinkedList<String>(Arrays.asList(tokens)); Regimen regimen = new Regimen(); while (tokenQueue.size() >= 4) { String drugRefStr = tokenQueue.remove().trim(); String doseStr = tokenQueue.remove().trim(); String units = tokenQueue.remove().trim(); String frequency = tokenQueue.remove().trim(); DrugReference drugRef = StringUtils.isNotEmpty(drugRefStr) ? drugReferenceConverter.convert(drugRefStr) : null; Double dose = StringUtils.isNotEmpty(doseStr) ? Double.parseDouble(doseStr) : null; units = StringUtils.isNotEmpty(units) ? units : null; frequency = StringUtils.isNotEmpty(frequency) ? frequency : null; regimen.getComponents().add(new RegimenComponent(drugRef, dose, units, frequency)); } return regimen; }
From source file:org.archive.bdb.StoredQueueTest.java
protected int drain(java.util.Queue<String> q) { int count = 0; while (true) { try {//from ww w . j av a 2s. c o m q.remove(); count++; } catch (NoSuchElementException nse) { return count; } } }
From source file:org.polymap.rhei.batik.engine.PanelContextInjector.java
@Override public void run() { Queue<Class> types = new ArrayDeque(16); types.add(panel.getClass());/*from www .j a v a2s . co m*/ while (!types.isEmpty()) { Class type = types.remove(); if (type.getSuperclass() != null) { types.add(type.getSuperclass()); } for (Field f : type.getDeclaredFields()) { // ContextProperty if (Context.class.isAssignableFrom(f.getType())) { f.setAccessible(true); Type ftype = f.getGenericType(); if (ftype instanceof ParameterizedType) { // set try { f.set(panel, new ContextPropertyInstance(f, context)); log.debug("injected: " + f.getName() + " (" + panel.getClass().getSimpleName() + ")"); continue; } catch (Exception e) { throw new RuntimeException(e); } } else { throw new IllegalStateException("ContextProperty has no type param: " + f.getName()); } } // @Context annotation Scope annotation = f.getAnnotation(Scope.class); if (annotation != null) { f.setAccessible(true); throw new UnsupportedOperationException("Injecting context property as direct member."); // Object value = context.get( f.getType() ); // // try { // f.set( panel, value ); // log.info( "injected: " + f.getName() + " <- " + value ); // } // catch (Exception e) { // throw new RuntimeException( e ); // } } } } }
From source file:org.esigate.http.OutgoingRequestContext.java
/** * remove attribute and restore previous attribute value * /*from w w w . ja va 2 s. co m*/ * @param id * attribute name * @param restore * restore previous attribute value * @return attribute value */ public Object removeAttribute(String id, boolean restore) { Object value = removeAttribute(id); if (restore) { String historyAttribute = id + "history"; Queue<Object> history = (Queue<Object>) getAttribute(historyAttribute); if (history != null && !history.isEmpty()) { Object previous = history.remove(); setAttribute(id, previous); } } return value; }