当前位置: 首页>>代码示例>>Java>>正文


Java Deque.poll方法代码示例

本文整理汇总了Java中java.util.Deque.poll方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.poll方法的具体用法?Java Deque.poll怎么用?Java Deque.poll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Deque的用法示例。


在下文中一共展示了Deque.poll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: declarationsDependsOn

import java.util.Deque; //导入方法依赖的package包/类
private boolean declarationsDependsOn(Snippet snip) {
    Deque<Snippet> candidates = new ArrayDeque();
    candidates.add(snip);
    while (!candidates.isEmpty()) {
        Snippet c = candidates.poll();
        Collection<Snippet> deps = JShellAccessor.getDependents(shellSession.ensureShell(), c);
        for (Snippet s : deps) {
            if (!s.kind().isPersistent()) {
                continue;
            }
            if (s.kind() == Snippet.Kind.IMPORT) {
                continue;
            }
            if (s.subKind() == SubKind.TEMP_VAR_EXPRESSION_SUBKIND) {
                candidates.push(s);
            } else {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:SnippetClassGenerator.java

示例2: hasMultipleSelectables

import java.util.Deque; //导入方法依赖的package包/类
private boolean hasMultipleSelectables(ElementNode.Description elementDescription) {
    Deque<ElementNode.Description> toProcess = new ArrayDeque<>();
    if (elementDescription != null) {
        toProcess.add(elementDescription);
    }
    boolean selectableFound = false;
    while (!toProcess.isEmpty()) {
        ElementNode.Description d = toProcess.poll();
        List<ElementNode.Description> subs = d.getSubs();
        if (subs == null) {
            if (d.isSelectable()) {
                if (selectableFound) {
                    return true;
                }
                selectableFound = true;
            }
        } else {            
            toProcess.addAll(subs);
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ElementSelectorPanel.java

示例3: selectAllNodes

import java.util.Deque; //导入方法依赖的package包/类
private void selectAllNodes(boolean select) {
    boolean oldScroll = elementView.getScrollsOnExpand();
    elementView.setScrollsOnExpand( false );
    Node root = getExplorerManager().getRootContext();
    Deque<Node> toProcess = new ArrayDeque<>(Arrays.asList(root.getChildren().getNodes(true)));
    while (!toProcess.isEmpty()) {
        Node n = toProcess.poll();
        ElementNode.Description desc = getDescription(n);
        if (desc == null) {
            continue;
        }
        if (desc.hasSelectableSubs()) {
            elementView.expandNode(n);
            toProcess.addAll(Arrays.asList(n.getChildren().getNodes(true)));
        } else if (desc.isSelectable()) {
            desc.setSelected(select);
        }
    }
    elementView.setScrollsOnExpand( oldScroll );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ElementSelectorPanel.java

示例4: getPathFromRoot

import java.util.Deque; //导入方法依赖的package包/类
/**
 * Constructs a path from the root of the document to the given syntax element.
 * 
 * @param element the element to start with
 * @return top-down path of SyntaxElements from the document root towards the original SyntaxElement
 */
public List<SyntaxElement> getPathFromRoot(SyntaxElement element) {
    Deque<SyntaxElement> stack = new ArrayDeque<>();
    SyntaxElement elementRef = element;
    while (elementRef != null) {
        if (isEndTag(element) ||
                (isEmptyTag(elementRef) && stack.isEmpty()) ||
                (isStartTag(elementRef) && stack.isEmpty())) {
            stack.push(elementRef);
            elementRef = elementRef.getPrevious();
            continue;
        }
        if (isStartTag(elementRef)) {
            if (isEndTag(stack.peek())) {
                SyntaxElement end = stack.peek();
                if (end.getNode().getNodeName().equals(elementRef.getNode().getNodeName())) {
                    stack.pop();
                }
            } else {
                SyntaxElement e = stack.peek();
                stack.push(elementRef);
            }
        }
        elementRef = elementRef.getPrevious();
    }
    // reverse:
    List<SyntaxElement> res = new ArrayList<>(stack.size());
    while ((elementRef = stack.poll()) != null) {
        res.add(elementRef);
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:XMLSyntaxSupport.java

示例5: checkConjestion

import java.util.Deque; //导入方法依赖的package包/类
/**
 * 检查路书中是否含有拥堵路段,所有拥堵路段都必须大于150米
 *
 * @param conditionDistances
 * @return
 */
private boolean checkConjestion(Deque<FormatTrafficNode> conditionDistances) {
    int l = conditionDistances.size();
    if (l == 0)
        return false;
    FormatTrafficNode t;
    while ((t = conditionDistances.poll()) != null) {
        if (t.getDistance() > 150) {
            return true;
        }
        conditionDistances.poll();
    }
    return false;
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:20,代码来源:NavigatorService.java

示例6: maxSlidingWindow

import java.util.Deque; //导入方法依赖的package包/类
public static int[] maxSlidingWindow(int[] nums, int k) {
    Deque<Integer> deque = new ArrayDeque<>();
    int n = nums.length;
    int[] res = new int[n - k + 1];
    for (int i = 0; i < n; i++) {
        if (!deque.isEmpty() && deque.peek() == i - k) deque.poll();
        while (!deque.isEmpty() && nums[deque.peekLast()] < nums[i]) deque.pollLast();
        deque.offer(i);
        if (i >= k - 1) {
            res[i + 1 - k] = nums[deque.peek()];
        }
    }
    return res;
}
 
开发者ID:xy1m,项目名称:PlayGround,代码行数:15,代码来源:MaxSlidingWindow.java

示例7: handleSingleArrayValue

import java.util.Deque; //导入方法依赖的package包/类
private static Node handleSingleArrayValue(final String string, final PredicateBuilder builder, final Deque<Token> tokens, final Token token, final ExchangeAttributeParser attributeParser) {
    String sv = builder.defaultParameter();
    if (sv == null) {
        throw error(string, token.position, "default parameter not supported");
    }
    Object array = readArrayType(string, tokens, new Token(sv, token.position), builder, attributeParser, "}");
    Token close = tokens.poll();
    if (!close.token.equals("]")) {
        throw error(string, close.position, "expected ]");
    }
    return new BuilderNode(builder, Collections.singletonMap(sv, array));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:PredicateParser.java

示例8: handleSingleArrayValue

import java.util.Deque; //导入方法依赖的package包/类
private static HandlerWrapper handleSingleArrayValue(final String string, final HandlerBuilder builder, final Deque<Token> tokens, final Token token, final ExchangeAttributeParser attributeParser) {
    String sv = builder.defaultParameter();
    if (sv == null) {
        throw error(string, token.position, "default parameter not supported");
    }
    Object array = readArrayType(string, tokens, new Token(sv, token.position), builder, attributeParser, "}");
    Token close = tokens.poll();
    if (!close.token.equals("]")) {
        throw error(string, close.position, "expected ]");
    }
    return builder.build(Collections.singletonMap(sv, array));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:HandlerParser.java

示例9: findAllDependencies

import java.util.Deque; //导入方法依赖的package包/类
/**
 * Find the dependencies of a class, using the current
 * {@link Dependencies#getFinder finder} and
 * {@link Dependencies#getFilter filter}.
 * The search may optionally include the transitive closure of all the
 * filtered dependencies, by also searching in the classes named in those
 * dependencies.
 * @param classFinder a finder to locate class files
 * @param rootClassNames the names of the root classes from which to begin
 *      searching
 * @param transitiveClosure whether or not to also search those classes
 *      named in any filtered dependencies that are found.
 * @param recorder a recorder for handling the results
 * @throws ClassFileNotFoundException if a required class file cannot be found
 * @throws ClassFileError if an error occurs while processing a class file,
 *      such as an error in the internal class file structure.
 */
public void findAllDependencies(
        ClassFileReader classFinder, Set<String> rootClassNames,
        boolean transitiveClosure, Recorder recorder)
        throws ClassFileNotFoundException {
    Set<String> doneClasses = new HashSet<String>();

    getFinder();  // ensure initialized
    getFilter();  // ensure initialized

    // Work queue of names of classfiles to be searched.
    // Entries will be unique, and for classes that do not yet have
    // dependencies in the results map.
    Deque<String> deque = new LinkedList<String>(rootClassNames);

    String className;
    while ((className = deque.poll()) != null) {
        assert (!doneClasses.contains(className));
        doneClasses.add(className);

        ClassFile cf = classFinder.getClassFile(className);

        // The following code just applies the filter to the dependencies
        // followed for the transitive closure.
        for (Dependency d: finder.findDependencies(cf)) {
            recorder.addDependency(d);
            if (transitiveClosure && filter.accepts(d)) {
                String cn = d.getTarget().getClassName();
                if (!doneClasses.contains(cn))
                    deque.add(cn);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:Dependencies.java

示例10: createMapping

import java.util.Deque; //导入方法依赖的package包/类
private static Map<Class, QName> createMapping(Class... implementations) {
    Map<Class, QName> result = new HashMap<>(implementations.length);
    for (Class implementation : implementations) {
        Deque<Class> toProcess = new ArrayDeque<>();
        toProcess.add(implementation);
        Class webServiceInterface = null;
        do {
            Class clazz = toProcess.poll();
            if (clazz.getAnnotation(WebService.class) != null && clazz.isInterface()) {
                webServiceInterface = clazz;
                break;
            }
            if (clazz.getSuperclass() != null) {
                toProcess.add(clazz.getSuperclass());
            }
            if (clazz.getInterfaces() != null) {
                toProcess.addAll(Arrays.asList(clazz.getInterfaces()));
            }
        }
        while (!toProcess.isEmpty());
        if (webServiceInterface != null) {
            WebService webService = (WebService)webServiceInterface.getAnnotation(WebService.class);
            String targetNamespace = webService.targetNamespace();
            if (targetNamespace.isEmpty()) {
                targetNamespace = getDefaultTargetNamespace(implementation);
            }
            String serviceName = webService.serviceName();
            if (serviceName.isEmpty()) {
                serviceName = getDefaultServiceName(implementation);
            }
            result.put(webServiceInterface, new QName(targetNamespace, serviceName));
        }
    }
    return result;
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:36,代码来源:RPCServiceImpl.java

示例11: DFA

import java.util.Deque; //导入方法依赖的package包/类
public<M extends IPredicateMap<P,T,State,M>> DFA(M factory, FSA<T,F,P> automaton, boolean debug) {
    this(factory);
    // Перезапускаем автомат и сохраняем стартовое состояние
    Set<State> old_initial=automaton.initialState();
    // Создаем отображение старых состояний на новые
    Map<Set<State>,State> old2new=new HashMap();
    State new_initial=debug?this.newState(old_initial,automaton):this.newState();
    old2new.put(old_initial,new_initial);
    // Создаем массив состояний, которые мы еще не рассмотрели
    Deque<Set<State>> unprocessed=new ArrayDeque();
    unprocessed.addLast(old_initial);        
    // Перебираем все состояния 
    Set<State> old_states;
    while((old_states=unprocessed.poll())!=null) {
        State active=old2new.get(old_states);
        // и делаем из состояния active все переходы.
        // Получаем все возможные символы для перехода.
        Map<P,Set<State>> old_transitions=DFA.purifyTransitions(automaton.getTransitions(old_states));
        // Маркируем остановочные состояния
        for(F mark: automaton.getMarkers(old_states))
            this.markState(active, mark);
        // Для каждого символа перехода
        for(Map.Entry<P,Set<State>> entry: old_transitions.entrySet()) {
            // Ищем куда ведет переход
            Set<State> old_targets=entry.getValue();
            automaton.doEpsilonTransition(old_targets);
            State target;
            if(old2new.containsKey(old_targets)) target=old2new.get(old_targets);
            else {
                target=debug?this.newState(old_targets,automaton):this.newState();
                old2new.put(old_targets,target);
                // Если состояние новое, то добавляем его в список непроанализированных состояний
                unprocessed.addLast(old_targets);
            };
            // Создаем переход в новом автомате
            this.newTransition(active,target,entry.getKey());
        };
    };
}
 
开发者ID:alepoydes,项目名称:writing-compiler-for-neophytes,代码行数:40,代码来源:DFA.java

示例12: parseTopologyTree

import java.util.Deque; //导入方法依赖的package包/类
protected synchronized void parseTopologyTree() {
  if (machineNodes == null) {
    Node root = getClusterTopology();
    SortedSet<MachineNode> mNodes = new TreeSet<MachineNode>();
    SortedSet<RackNode> rNodes = new TreeSet<RackNode>();
    // dfs search of the tree.
    Deque<Node> unvisited = new ArrayDeque<Node>();
    Deque<Integer> distUnvisited = new ArrayDeque<Integer>();
    unvisited.add(root);
    distUnvisited.add(0);
    for (Node n = unvisited.poll(); n != null; n = unvisited.poll()) {
      int distance = distUnvisited.poll();
      if (n instanceof RackNode) {
        rNodes.add((RackNode) n);
        mNodes.addAll(((RackNode) n).getMachinesInRack());
        if (distance + 1 > maximumDistance) {
          maximumDistance = distance + 1;
        }
      } else if (n instanceof MachineNode) {
        mNodes.add((MachineNode) n);
        if (distance > maximumDistance) {
          maximumDistance = distance;
        }
      } else {
        for (Node child : n.getChildren()) {
          unvisited.addFirst(child);
          distUnvisited.addFirst(distance+1);
        }
      }
    }

    machineNodes = Collections.unmodifiableSortedSet(mNodes);
    rackNodes = Collections.unmodifiableSortedSet(rNodes);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:AbstractClusterStory.java

示例13: transitiveDeps

import java.util.Deque; //导入方法依赖的package包/类
private void transitiveDeps(int depth) throws IOException {
    Stream<Location> deps = archives.stream()
                                    .flatMap(Archive::getDependencies);

    Deque<Location> unresolved = deps.collect(Collectors.toCollection(LinkedList::new));
    ConcurrentLinkedDeque<Location> deque = new ConcurrentLinkedDeque<>();
    do {
        Location target;
        while ((target = unresolved.poll()) != null) {
            if (finder.isParsed(target))
                continue;

            Archive archive = configuration.findClass(target).orElse(null);
            if (archive != null) {
                archives.add(archive);

                String name = target.getName();
                Set<Location> targets = apiOnly
                        ? finder.parseExportedAPIs(archive, name)
                        : finder.parse(archive, name);

                // build unresolved dependencies
                targets.stream()
                       .filter(t -> !finder.isParsed(t))
                       .forEach(deque::add);
            }
        }
        unresolved = deque;
        deque = new ConcurrentLinkedDeque<>();
    } while (!unresolved.isEmpty() && depth-- > 0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:DepsAnalyzer.java

示例14: buildGraph

import java.util.Deque; //导入方法依赖的package包/类
/**
 * Build a graph of module from the given dependences.
 *
 * It transitively includes all implied read edges.
 */
private Graph<Module> buildGraph(Map<Module, Set<Module>> edges) {
    Graph.Builder<Module> builder = new Graph.Builder<>();
    Set<Module> visited = new HashSet<>();
    Deque<Module> deque = new LinkedList<>();
    edges.entrySet().stream().forEach(e -> {
        Module m = e.getKey();
        deque.add(m);
        e.getValue().stream().forEach(v -> {
            deque.add(v);
            builder.addEdge(m, v);
        });
    });

    // read requires transitive from ModuleDescriptor
    Module source;
    while ((source = deque.poll()) != null) {
        if (visited.contains(source))
            continue;

        visited.add(source);
        builder.addNode(source);
        Module from = source;
        requiresTransitive(from).forEach(m -> {
            deque.add(m);
            builder.addEdge(from, m);
        });
    }
    return builder.build();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:ModuleGraphBuilder.java

示例15: maxSlidingWindow

import java.util.Deque; //导入方法依赖的package包/类
public int[] maxSlidingWindow(int[] nums, int k) {
    if (k == 0) {
        return new int[0];
    }

    int n = nums.length;

    int[] result = new int[n - k + 1];
    int current = 0;

    Deque<Integer> deque = new ArrayDeque<>();

    for (int i = 0; i < n; i++) {
        while (!deque.isEmpty() && deque.peek() < i - k + 1) {
            deque.poll();
        }

        while(!deque.isEmpty() && nums[deque.peekLast()] < nums[i]) {
            deque.pollLast();
        }

        deque.offer(i);

        if (i >= k - 1) { // allowing sliding window to fit in full initially
            result[current++] = nums[deque.peek()];
        }
    }

    return result;
}
 
开发者ID:viatsko,项目名称:hack,代码行数:31,代码来源:SlidingWindowMaximum.java


注:本文中的java.util.Deque.poll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。