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


Java Deque类代码示例

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


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

示例1: testPrepare

import java.util.Deque; //导入依赖的package包/类
@Test(timeout = 1000)
public void testPrepare() throws IOException {
  And and = new And();
  Expression first = mock(Expression.class);
  Expression second = mock(Expression.class);

  Deque<Expression> children = new LinkedList<Expression>();
  children.add(second);
  children.add(first);
  and.addChildren(children);

  and.prepare();
  verify(first).prepare();
  verify(second).prepare();
  verifyNoMoreInteractions(first);
  verifyNoMoreInteractions(second);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestAnd.java

示例2: doBuildResolvedResult

import java.util.Deque; //导入依赖的package包/类
private List<DependentBinariesResolvedResult> doBuildResolvedResult(final NativeBinarySpecInternal target, State state, Deque<NativeBinarySpecInternal> stack) {
    if (stack.contains(target)) {
        onCircularDependencies(state, stack, target);
    }
    List<DependentBinariesResolvedResult> result = resultsCache.getIfPresent(target);
    if (result != null) {
        return result;
    }
    stack.push(target);
    result = Lists.newArrayList();
    List<NativeBinarySpecInternal> dependents = state.getDependents(target);
    for (NativeBinarySpecInternal dependent : dependents) {
        List<DependentBinariesResolvedResult> children = doBuildResolvedResult(dependent, state, stack);
        result.add(new DefaultDependentBinariesResolvedResult(dependent.getId(), dependent.getProjectScopedName(), dependent.isBuildable(), isTestSuite(dependent), children));
    }
    stack.pop();
    resultsCache.put(target, result);
    return result;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:NativeDependentBinariesResolutionStrategy.java

示例3: findNextLeafNode

import java.util.Deque; //导入依赖的package包/类
/**
 * Depth first search, in left-to-right order, of the node tree, using
 * an explicit stack, to find the next non-empty leaf node.
 */
@SuppressWarnings("unchecked")
protected final N findNextLeafNode(Deque<N> stack) {
    N n = null;
    while ((n = stack.pollFirst()) != null) {
        if (n.getChildCount() == 0) {
            if (n.count() > 0)
                return n;
        } else {
            for (int i = n.getChildCount() - 1; i >= 0; i--)
                stack.addFirst((N) n.getChild(i));
        }
    }

    return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:Nodes.java

示例4: testSeqPref

import java.util.Deque; //导入依赖的package包/类
public void testSeqPref() throws Exception {
    JavaIndexerWorker.TEST_DO_PREFETCH = false;
    final LogHandler handler = new LogHandler();
    handler.expect("Using sequential iterator");    //NOI18N
    final Logger log = Logger.getLogger(JavaIndexerWorker.class.getName());
    log.setLevel(Level.FINE);
    log.addHandler(handler);
    try {
        SourcePrefetcher pf = SourcePrefetcher.create(files, SuspendSupport.NOP);
        assertTrue(handler.isFound());
        final Deque<CompileTuple> got = new ArrayDeque<CompileTuple>(FILE_COUNT);
        while (pf.hasNext()) {
            final CompileTuple ct = pf.next();
            assertNull(getCache(ct.jfo));
            got.offer(ct);
            pf.remove();
        }
        assertCollectionsEqual(files,got);
    } finally {
        log.removeHandler(handler);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:SourcePrefetcherTest.java

示例5: extractDims

import java.util.Deque; //导入依赖的package包/类
/**
 * Accumulates a flattened list of array dimensions specifiers with type annotations, and returns
 * the base type.
 * <p>
 * <p>Given {@code int @A @B [][] @C []}, adds {@code [[@A, @B], [@C]]} to dims and returns {@code
 * int}.
 */
private static Tree extractDims(Deque<List<AnnotationTree>> dims, Tree node) {
    switch (node.getKind()) {
        case ARRAY_TYPE:
            return extractDims(dims, ((ArrayTypeTree) node).getType());
        // TODO: 22-Jul-17 missing type
       /* case ANNOTATED_TYPE:
            AnnotatedTypeTree annotatedTypeTree = (AnnotatedTypeTree) node;
            if (annotatedTypeTree.getUnderlyingType().getKind() != Tree.Kind.ARRAY_TYPE) {
                return node;
            }
            node = extractDims(dims, annotatedTypeTree.getUnderlyingType());
            dims.addFirst(ImmutableList.<AnnotationTree>copyOf(annotatedTypeTree.getAnnotations()));
            return node;*/
        default:
            return node;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:25,代码来源:DimensionHelpers.java

示例6: main

import java.util.Deque; //导入依赖的package包/类
/**
 * Main method of the example. Creates three WriterTasks and a CleanerTask
 * 
 * @param args
 */
public static void main(String[] args) {

	// Creates the Event data structure
	Deque<Event> deque = new ConcurrentLinkedDeque<>();

	// Creates the three WriterTask and starts them
	WriterTask writer = new WriterTask(deque);
	for (int i = 0; i < Runtime.getRuntime().availableProcessors(); i++) {
		Thread thread = new Thread(writer);
		thread.start();
	}

	// Creates a cleaner task and starts them
	CleanerTask cleaner = new CleanerTask(deque);
	cleaner.start();

}
 
开发者ID:PacktPublishing,项目名称:Java-SE-9-Road-to-Concurrent-and-High-Performance-Programming,代码行数:23,代码来源:Main.java

示例7: doLoad

import java.util.Deque; //导入依赖的package包/类
private Optional<SelectedSnapshot> doLoad(final Deque<SnapshotMetadata> metadatas) throws IOException {
    SnapshotMetadata metadata = metadatas.removeFirst();
    File file = toSnapshotFile(metadata);

    LOG.debug("doLoad {}", file);

    try {
        Object data = deserialize(file);

        LOG.debug("deserialized data: {}", data);

        return Optional.of(new SelectedSnapshot(metadata, data));
    } catch (IOException e) {
        LOG.error("Error loading snapshot file {}, remaining attempts: {}", file, metadatas.size(), e);

        if (metadatas.isEmpty()) {
            throw e;
        }

        return doLoad(metadatas);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:LocalSnapshotStore.java

示例8: chooseDbSource

import java.util.Deque; //导入依赖的package包/类
public static File chooseDbSource(Shell shell, IPreferenceStore prefStore, boolean dir) {
    String pathToDump = dir ? getDirPath(shell, prefStore) : getFilePath(shell, prefStore);
    if (pathToDump == null) {
        return null;
    }

    File dumpFile = new File(pathToDump);
    Deque<File> dumpHistory = stringToDumpFileHistory(prefStore.getString(PREF.DB_STORE_FILES));
    dumpHistory.addFirst(dumpFile);
    while (dumpHistory.size() > MAX_FILES_HISTORY) {
        dumpHistory.removeLast();
    }
    prefStore.setValue(PREF.DB_STORE_FILES, dumpFileHistoryToPreference(dumpHistory));
    prefStore.setValue(PREF.LAST_OPENED_LOCATION,
            dir ? dumpFile.getAbsolutePath() : dumpFile.getParent());
    return dumpFile;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:18,代码来源:DbStorePicker.java

示例9: forEachRemaining

import java.util.Deque; //导入依赖的package包/类
@Override
public void forEachRemaining(Consumer<? super T> consumer) {
    if (curNode == null)
        return;

    if (tryAdvanceSpliterator == null) {
        if (lastNodeSpliterator == null) {
            Deque<Node<T>> stack = initStack();
            Node<T> leaf;
            while ((leaf = findNextLeafNode(stack)) != null) {
                leaf.forEach(consumer);
            }
            curNode = null;
        }
        else
            lastNodeSpliterator.forEachRemaining(consumer);
    }
    else
        while(tryAdvance(consumer)) { }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Nodes.java

示例10: rewriteHistory

import java.util.Deque; //导入依赖的package包/类
@Test
public void rewriteHistory() {
  navigator.onCreate(activity, null);
  navigator.goTo(screen);

  assertThat(navigator.currentScreen()).isEqualTo(screen);

  navigator.onDestroy(activity);

  navigator.rewriteHistory(activity, new HistoryRewriter() {
    @Override
    public void rewriteHistory(Deque<Screen> history) {
      history.pop();
    }
  });

  assertThat(navigator.currentScreen()).isEqualTo(root);
}
 
开发者ID:wealthfront,项目名称:magellan,代码行数:19,代码来源:NavigatorTest.java

示例11: navigate

import java.util.Deque; //导入依赖的package包/类
@Test
public void navigate() {
  when(screen.shouldShowActionBar()).thenReturn(false);
  when(screen2.shouldShowActionBar()).thenReturn(true);

  navigator.onCreate(activity, null);
  navigator.goTo(screen);

  navigator.navigate(new HistoryRewriter() {
    @Override
    public void rewriteHistory(Deque<Screen> history) {
      history.clear();
      history.push(root);
      history.push(screen2);
    }
  });

  verify(screen).onHide(activity);
  verify(screen2).onShow(activity);
  assertThat(navigator.currentScreen()).isEqualTo(screen2);
}
 
开发者ID:wealthfront,项目名称:magellan,代码行数:22,代码来源:NavigatorTest.java

示例12: toStyleProcessorOverThreshold

import java.util.Deque; //导入依赖的package包/类
@Test
public void toStyleProcessorOverThreshold() {
	final Deque<Object> contextData = new ArrayDeque<>();
	contextData.add(1); // Index
	final SlaData data = new SlaData();
	data.setDuration(13L); // Duration;
	contextData.add(data);
	final JiraSlaComputations slaComputations = new JiraSlaComputations();
	final SlaConfiguration slaConfiguration0 = new SlaConfiguration();
	slaConfiguration0.setThreshold(14);
	final SlaConfiguration slaConfiguration1 = new SlaConfiguration();
	slaConfiguration1.setThreshold(12);
	slaComputations.setSlaConfigurations(Arrays.asList(slaConfiguration0, slaConfiguration1));
	Assert.assertEquals("invalid", resource.toStyleProcessor(slaComputations, "normal", "invalid").getValue(contextData));

}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:17,代码来源:JiraExportPluginResourceTest.java

示例13: forEachRemaining

import java.util.Deque; //导入依赖的package包/类
@Override
public void forEachRemaining(T_CONS consumer) {
    if (curNode == null)
        return;

    if (tryAdvanceSpliterator == null) {
        if (lastNodeSpliterator == null) {
            Deque<N> stack = initStack();
            N leaf;
            while ((leaf = findNextLeafNode(stack)) != null) {
                leaf.forEach(consumer);
            }
            curNode = null;
        }
        else
            lastNodeSpliterator.forEachRemaining(consumer);
    }
    else
        while(tryAdvance(consumer)) { }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:Nodes.java

示例14: visitDepthFirst

import java.util.Deque; //导入依赖的package包/类
private void visitDepthFirst(AST ast) {
	if ( ast == null ) {
		return;
	}
	Deque<AST> stack = new ArrayDeque<AST>();
	stack.addLast( ast );
	while ( !stack.isEmpty() ) {
		ast = stack.removeLast();
		strategy.visit( ast );
		if ( ast.getNextSibling() != null ) {
			stack.addLast( ast.getNextSibling() );
		}
		if ( ast.getFirstChild() != null ) {
			stack.addLast( ast.getFirstChild() );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:NodeTraverser.java

示例15: floodIndices

import java.util.Deque; //导入依赖的package包/类
private Set<Coordinate> floodIndices(final Coordinate coordinate) {
    final Set<Coordinate> flood = new LinkedHashSet<>();
    final Color floodColor = getColor(coordinate);
    final Deque<Coordinate> queue = new LinkedList<>();
    queue.add(coordinate);

    while (!queue.isEmpty()) {
        final Coordinate location = queue.pop();
        flood.add(location);

        queue.addAll(getNeighbors(location).stream()
            .filter(neighbor -> floodColor.equals(getColor(neighbor)) && !flood.contains(neighbor))
            .collect(Collectors.toList()));
    }

    return flood;
}
 
开发者ID:neocotic,项目名称:brick-pop-solver,代码行数:18,代码来源:Board.java


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