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


Java Queues.newArrayDeque方法代码示例

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


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

示例1: ParticleManager

import com.google.common.collect.Queues; //导入方法依赖的package包/类
public ParticleManager(World worldIn, TextureManager rendererIn)
{
    this.worldObj = worldIn;
    this.renderer = rendererIn;

    for (int i = 0; i < 4; ++i)
    {
        this.fxLayers[i] = new ArrayDeque[2];

        for (int j = 0; j < 2; ++j)
        {
            this.fxLayers[i][j] = Queues.newArrayDeque();
        }
    }

    this.registerVanillaParticles();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:ParticleManager.java

示例2: floodFill

import com.google.common.collect.Queues; //导入方法依赖的package包/类
private Set<EnumFacing> floodFill(int p_178604_1_)
{
    Set<EnumFacing> set = EnumSet.<EnumFacing>noneOf(EnumFacing.class);
    Queue<Integer> queue = Queues.<Integer>newArrayDeque();
    queue.add(IntegerCache.getInteger(p_178604_1_));
    this.bitSet.set(p_178604_1_, true);

    while (!((Queue)queue).isEmpty())
    {
        int i = ((Integer)queue.poll()).intValue();
        this.addEdges(i, set);

        for (EnumFacing enumfacing : EnumFacing.values())
        {
            int j = this.getNeighborIndexAtFace(i, enumfacing);

            if (j >= 0 && !this.bitSet.get(j))
            {
                this.bitSet.set(j, true);
                queue.add(IntegerCache.getInteger(j));
            }
        }
    }

    return set;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:27,代码来源:VisGraph.java

示例3: bfsLists

import com.google.common.collect.Queues; //导入方法依赖的package包/类
/**
 * Do a breadth-first search over the given collection of lists, applying the supplied function
 * to each item in the list.  If the function returns an explicit true (not null or false)
 * the search will abort.
 *
 * @param toTraverse the lists to traverse (breadth-first)
 * @param toApply the function to apply (if it returns true the search will abort)
 * @return the number of lists visited (inclusive)
 */
public static int bfsLists(Collection<WFList> toTraverse, Function<WFList, Boolean> toApply) {
    if (toTraverse == null) return 0;

    int numVisited = 0;
    Queue<WFList> visitQueue = Queues.newArrayDeque(toTraverse);
    while (!visitQueue.isEmpty()) {
        numVisited++;
        WFList cur = visitQueue.remove();
        Boolean abort = toApply.apply(cur);
        if (abort != null && abort.equals(true)) {
            break;
        }
        if (cur.getChildren() != null) {
            visitQueue.addAll(cur.getChildren());
        }
    }
    return numVisited;
}
 
开发者ID:rmnoon,项目名称:WorkflowyList,代码行数:28,代码来源:Utils.java

示例4: pathExistsDirectional

import com.google.common.collect.Queues; //导入方法依赖的package包/类
/**
 * Route Between Nodes: Find whether there is a path between two nodes (A->B) in a directed graph.
 *
 * Assumptions:
 *
 * Time complexity: O(n)
 * Space complexity: O(n)
 *
 * Notes: Simple breadth first search.
 */
public static boolean pathExistsDirectional(IntNode a, IntNode b, IntGraph graph) {
  if (a == b) {
    return true;
  }

  Queue<IntNode> queue = Queues.newArrayDeque();
  Set<IntNode> visited = Sets.newHashSet();
  queue.add(a);
  visited.add(a);

  while (!queue.isEmpty()) {
    IntNode next = queue.remove();
    for (Node<Integer> adjacent : next.getAdjacent()) {
      if (adjacent == b) {
        return true;
      } else if (visited.add((IntNode) adjacent)) {
        queue.add((IntNode) adjacent);
      }
    }  
  }

  return false;
}
 
开发者ID:myyk,项目名称:cracking-the-coding-interview-6th,代码行数:34,代码来源:Chapter4Solutions.java

示例5: pathExistsBidirectional

import com.google.common.collect.Queues; //导入方法依赖的package包/类
/**
 * Route Between Nodes: Modified - Find whether there is a path between two nodes (A->B) in a bidirectional graph.
 *
 * Assumptions:
 *
 * Time complexity: O(n) where n is numer of nodes
 * Space complexity: O(n)
 */
public static boolean pathExistsBidirectional(IntNode a, IntNode b) {
  // BFS on both nodes at the same time
  Queue<IntNode> queueA = Queues.newArrayDeque();
  Queue<IntNode> queueB = Queues.newArrayDeque();
  Set<IntNode> visitedA = Sets.newHashSet();
  Set<IntNode> visitedB = Sets.newHashSet();

  visitedA.add(a);
  visitedB.add(b);
  queueA.add(a);
  queueB.add(b);

  while (!queueA.isEmpty() && !queueB.isEmpty()) {
    if (pathExistsBidirectionalHelper(queueA, visitedA, visitedB)) {
      return true;
    }
    if (pathExistsBidirectionalHelper(queueB, visitedB, visitedA)) {
      return true;
    }
  }

  return false;
}
 
开发者ID:myyk,项目名称:cracking-the-coding-interview-6th,代码行数:32,代码来源:Chapter4Solutions.java

示例6: targetsForSourceFileImpl

import com.google.common.collect.Queues; //导入方法依赖的package包/类
private Collection<TargetIdeInfo> targetsForSourceFileImpl(
    ImmutableMultimap<TargetKey, TargetKey> rdepsMap, File sourceFile) {
  List<TargetIdeInfo> result = Lists.newArrayList();
  Collection<TargetKey> roots = rootsMap.get(sourceFile);

  Queue<TargetKey> todo = Queues.newArrayDeque();
  todo.addAll(roots);
  Set<TargetKey> seen = Sets.newHashSet();
  while (!todo.isEmpty()) {
    TargetKey targetKey = todo.remove();
    if (!seen.add(targetKey)) {
      continue;
    }

    TargetIdeInfo target = targetMap.get(targetKey);
    if (filter.test(target)) {
      result.add(target);
    }
    todo.addAll(rdepsMap.get(targetKey));
  }
  return result;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:23,代码来源:FilteredTargetMap.java

示例7: schemaPathToFieldPath

import com.google.common.collect.Queues; //导入方法依赖的package包/类
/**
 * Returns {@link FieldPath} equivalent of the specified {@link SchemaPath}.
 *
 * @param schemaPath {@link SchemaPath} instance that should be converted
 * @return {@link FieldPath} equivalent of the specified {@link SchemaPath}.
 */
public static FieldPath schemaPathToFieldPath(SchemaPath schemaPath) {
  Deque<PathSegment> pathSegments = Queues.newArrayDeque();
  PathSegment pathSegment = schemaPath.getRootSegment();
  while (pathSegment != null) {
    pathSegments.push(pathSegment);
    pathSegment = pathSegment.getChild();
  }

  FieldSegment child = null;
  while (!pathSegments.isEmpty()) {
    pathSegment = pathSegments.pop();
    if (pathSegment.isNamed()) {
      child = new FieldSegment.NameSegment(((PathSegment.NameSegment) pathSegment).getPath(), child, false);
    } else {
      child = new FieldSegment.IndexSegment(String.valueOf(((PathSegment.ArraySegment) pathSegment).getIndex()), child);
    }
  }
  return new FieldPath((FieldSegment.NameSegment) child);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:26,代码来源:FieldPathHelper.java

示例8: executeSoot

import com.google.common.collect.Queues; //导入方法依赖的package包/类
private static Scene executeSoot(Collection<String> methodSignatures) {
    IoSinkExpressions sinkExpressions = new IoSinkExpressions(Scene.v());

    Set<MethodAnalysis> processed = Sets.newHashSet();
    Queue<MethodAnalysis> queue = Queues.newArrayDeque(methodSignatures.stream()
                                                                       .map(s -> Scene.v().getMethod(s))
                                                                       .map(MethodAnalysis::new)
                                                                       .collect(Collectors.toSet()));

    PackManager.v().getPack("wjtp").add(
            new Transform("wjtp.dataFlowTransform", new SceneTransformer() {
                @Override protected void internalTransform(String phaseName, Map options) {
                    processQueue(queue, processed, sinkExpressions);
                }
            }));

    PackManager.v().runPacks();
    PackManager.v().writeOutput();
    return Scene.v();
}
 
开发者ID:uwdb,项目名称:pipegen,代码行数:21,代码来源:Optimizer.java

示例9: insertItemIntoListRemoveRedundantCommas

import com.google.common.collect.Queues; //导入方法依赖的package包/类
@Override
@NotNull
public PsiElement insertItemIntoListRemoveRedundantCommas(
  @NotNull final PyElement list,
  @Nullable final PyExpression afterThis,
  @NotNull final PyExpression toInsert) {
  // TODO: #insertItemIntoList is probably buggy. In such case, fix it and get rid of this method
  final PsiElement result = insertItemIntoList(list, afterThis, toInsert);
  final LeafPsiElement[] leafs = PsiTreeUtil.getChildrenOfType(list, LeafPsiElement.class);
  if (leafs != null) {
    final Deque<LeafPsiElement> commas = Queues.newArrayDeque(Collections2.filter(Arrays.asList(leafs), COMMAS_ONLY));
    if (!commas.isEmpty()) {
      final LeafPsiElement lastComma = commas.getLast();
      if (PsiTreeUtil.getNextSiblingOfType(lastComma, PyExpression.class) == null) { //Comma has no expression after it
        lastComma.delete();
      }
    }
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PyElementGeneratorImpl.java

示例10: getTransitiveDependencies

import com.google.common.collect.Queues; //导入方法依赖的package包/类
public static ImmutableCollection<TargetKey> getTransitiveDependencies(
    Collection<TargetKey> targetKeys, TargetMap targetMap) {
  Queue<TargetKey> targetsToVisit = Queues.newArrayDeque();
  Set<TargetKey> transitiveDependencies = Sets.newHashSet();
  targetsToVisit.addAll(targetKeys);
  while (!targetsToVisit.isEmpty()) {
    TargetIdeInfo currentTarget = targetMap.get(targetsToVisit.remove());
    if (currentTarget == null) {
      continue;
    }
    List<TargetKey> newDependencies =
        currentTarget
            .dependencies
            .stream()
            .map(d -> TargetKey.forPlainTarget(d.targetKey.label))
            // Get rid of the ones we've already seen.
            .filter(r -> !transitiveDependencies.contains(r))
            .collect(Collectors.toList());
    targetsToVisit.addAll(newDependencies);
    transitiveDependencies.addAll(newDependencies);
  }
  return ImmutableSet.copyOf(transitiveDependencies);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:24,代码来源:TransitiveDependencyMap.java

示例11: willRewrite

import com.google.common.collect.Queues; //导入方法依赖的package包/类
private boolean willRewrite(Production production) {
	// fill worker queue
	Deque<Production> openProduction = Queues.newArrayDeque();
	openProduction.offer(production);
	// till no production to consider ...
	while (openProduction.isEmpty() == false) {
		Production currentProduction = openProduction.poll();
		if (currentProduction instanceof RewriteProduction) {
			// we're not done, for sure, as we found a rewrite production
			return true;
		} else if (currentProduction instanceof BranchProduction<?>) {
			BranchProduction<?> branchProduction = (BranchProduction<?>) currentProduction;
			List<Production> branchInnerProductions = branchProduction.getRuleProductions(-1);
			for (Production branchInnerProduction : branchInnerProductions) {
				openProduction.offer(branchInnerProduction);
			}
		}
	}
	return false;
}
 
开发者ID:thotro,项目名称:linn,代码行数:21,代码来源:LinnExecutor.java

示例12: clear

import com.google.common.collect.Queues; //导入方法依赖的package包/类
protected void clear(Commit<Void> commit) {
    Queue<DocumentPath> toClearQueue = Queues.newArrayDeque();
    Map<String, Versioned<byte[]>> topLevelChildren = docTree.getChildren(DocumentPath.from("root"));
    toClearQueue.addAll(topLevelChildren.keySet()
            .stream()
            .map(name -> new DocumentPath(name, DocumentPath.from("root")))
            .collect(Collectors.toList()));
    while (!toClearQueue.isEmpty()) {
        DocumentPath path = toClearQueue.remove();
        Map<String, Versioned<byte[]>> children = docTree.getChildren(path);
        if (children.size() == 0) {
            docTree.removeNode(path);
        } else {
            children.keySet().forEach(name -> toClearQueue.add(new DocumentPath(name, path)));
            toClearQueue.add(path);
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:19,代码来源:AtomixDocumentTreeService.java

示例13: getAllPreviousDocs

import com.google.common.collect.Queues; //导入方法依赖的package包/类
@Nonnull
Iterator<NodeDocument> getAllPreviousDocs() {
    if (getPreviousRanges().isEmpty()) {
        return Iterators.emptyIterator();
    }
    //Currently this method would fire one query per previous doc
    //If that poses a problem we can try to find all prev doc by relying
    //on property that all prevDoc id would starts <depth+2>:p/path/to/node
    return new AbstractIterator<NodeDocument>(){
        private Queue<Map.Entry<Revision, Range>> previousRanges =
                Queues.newArrayDeque(getPreviousRanges().entrySet());
        @Override
        protected NodeDocument computeNext() {
            if(!previousRanges.isEmpty()){
                Map.Entry<Revision, Range> e = previousRanges.remove();
                NodeDocument prev = getPreviousDoc(e.getKey(), e.getValue());
                if(prev != null){
                    previousRanges.addAll(prev.getPreviousRanges().entrySet());
                    return prev;
                }
            }
            return endOfData();
        }
    };
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:26,代码来源:NodeDocument.java

示例14: testForwardingOfRequests

import com.google.common.collect.Queues; //导入方法依赖的package包/类
@Test
public void testForwardingOfRequests() throws Exception {

  Queue<RequestAndCallback> queue = Queues.newArrayDeque();

  BatchedPermitsRequester container = BatchedPermitsRequester.builder().resourceId("resource")
      .requestorIdentifier("requestor").requestSender(new TestRequestSender(queue, false)).build();
  try (ParallelRequester requester = new ParallelRequester(container)) {

    Future<Boolean> future = requester.request(10);

    await(new QueueSize(queue, 1), 1000);
    Assert.assertEquals(queue.size(), 1);
    satisfyRequestBuilder().requestAndCallback(queue.poll()).satisfy();

    future.get(1, TimeUnit.SECONDS);
    Assert.assertTrue(future.isDone());
    Assert.assertTrue(future.get());
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:21,代码来源:BatchedPermitsRequesterTest.java

示例15: testRetriableFail

import com.google.common.collect.Queues; //导入方法依赖的package包/类
@Test
public void testRetriableFail() throws Exception {
  Queue<RequestAndCallback> queue = Queues.newArrayDeque();

  BatchedPermitsRequester container = BatchedPermitsRequester.builder().resourceId("resource")
      .requestorIdentifier("requestor").requestSender(new TestRequestSender(queue, false)).build();
  try (ParallelRequester requester = new ParallelRequester(container)) {

    Future<Boolean> future = requester.request(10);

    for (int i = 0; i < BatchedPermitsRequester.MAX_RETRIES; i++) {
      // container will fail 5 times
      await(new QueueSize(queue, 1), 1000);
      Assert.assertFalse(future.isDone());
      failRequestBuilder().requestAndCallback(queue.poll()).fail();
    }

    // should return a failure
    Assert.assertFalse(future.get());
    // should not make any more request
    Assert.assertEquals(queue.size(), 0);
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:24,代码来源:BatchedPermitsRequesterTest.java


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